Michael Jennings wrote: > Lis Maria wrote: > > I am trying to run some sqls at the post installation of the RPM.At > > the beginning of the %post section, i am doing a su - <user> . But > > the sqls are getting executed as root itself. If the following is what you are doing then it is not going to work. su - $SOMEUSER some sql commands The 'su' spawns a command shell. That shell reads input until end of file. The input from the script will be /dev/null. That will terminate the su command. The su will exit. The following commands will be run as the root user. > When you use "su" in a shell script, you don't expect the rest of the > shell script to run as the su'd user, do you? So why would you expect > a %post scriptlet to do it? Agreed. But this is not obvious to everyone. > su - <user> -c /bin/sh -c " > <sql commands here> > " > > Something closer to that is what you need. Good suggestion. But the -c already spawns a /bin/sh and so a second explicit one is not needed. su - <user> -c "<sql commands here>" Personally I liked the old traditional style of using echo to pipe the commands in better. It is personal preference. echo sql commands | su $USER Bob _______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list