LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash scripting (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scripting-577043/)

saje 08-14-2007 12:26 PM

Bash scripting
 
This script not work.
I want connect from non root user connect to
database
#!/bin/
poveziSQL(){
sleep 5
echo "password "
#password for root
sleep 5
echo "su postgres \n"
sleep 5

echo "psql test"
echo "INSERT INTO test(test) VALUES("test")"
echo"\q"
}|su

jlliagre 08-14-2007 12:30 PM

Have a look at the "expect" command.

Matir 08-14-2007 07:23 PM

Also, why are you sleeping all the time? Generally no need to do that.

custangro 08-14-2007 09:49 PM

Quote:

Originally Posted by saje (Post 2858714)
#!/bin/

That isn't a valid shell. Isn't this supposed to be

Code:

#!/bin/bash

Tinkster 08-22-2007 08:03 PM

I don't understand the idea behind the script, either. Firstly
root won't need a password to su, secondly you're throwing the
password into the void; if the password were necessary (which
it isn't) you'd want to do
echo "password" | su postgres
No sleeps, and definitely not just an echo in the hopes that
something 2 lines down the script will magically know about it
because it showed on the screen 5 seconds ago



Cheers,
Tink


All times are GMT -5. The time now is 08:29 AM.