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 |
Have a look at the "expect" command.
|
Also, why are you sleeping all the time? Generally no need to do that.
|
Quote:
Code:
#!/bin/bash |
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. |