Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-14-2007, 01:26 PM   #1
LQ Newbie
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
Bash scripting

This script not work.
I want connect from non root user connect to
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")"
Old 08-14-2007, 01:30 PM   #2
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,723

Rep: Reputation: 433Reputation: 433Reputation: 433Reputation: 433Reputation: 433
Have a look at the "expect" command.
Old 08-14-2007, 08:23 PM   #3
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
Also, why are you sleeping all the time? Generally no need to do that.
Old 08-14-2007, 10:49 PM   #4
Senior Member
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,977
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Originally Posted by saje View Post
That isn't a valid shell. Isn't this supposed to be

Old 08-22-2007, 09:03 PM   #5
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
new to bash scripting peok Programming 2 07-15-2006 03:46 AM
help on bash scripting Kendo1979 Linux - Newbie 3 05-17-2005 08:10 PM
Bash Scripting Darklight451 Programming 1 10-07-2004 02:48 AM
help with bash scripting spuzzzzzzz Programming 2 09-03-2004 12:42 AM
need help with bash scripting rich2oo1 Programming 2 12-17-2003 01:50 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:33 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration