LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-14-2007, 01:26 PM   #1
saje
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
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
 
Old 08-14-2007, 01:30 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,649

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

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

Rep: Reputation: 208Reputation: 208Reputation: 208
Quote:
Originally Posted by saje View Post
#!/bin/
That isn't a valid shell. Isn't this supposed to be

Code:
#!/bin/bash
 
Old 08-22-2007, 09:03 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
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



Cheers,
Tink
 
  


Reply


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


All times are GMT -5. The time now is 06:55 PM.

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