LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-01-2012, 10:01 AM   #1
glamiss
LQ Newbie
 
Registered: May 2012
Location: minneapolis
Distribution: rhel 3/4 (soon to add 5)
Posts: 9

Rep: Reputation: Disabled
passing multiple inputs to script that calls other script(s)


i have a script, blah.sh. within, it calls bleh.sh. bleh.sh has a read <variable> point. blah.sh (also) has a (separate) read <variable> point. what i want to be able to do is send the first read variable and the second read variable to the blah.sh script (for example, y and y)

bleh.sh:
Code:
#!/bin/sh

echo "enter bleh: "
read bleh

if [ $bleh = "y" -o $bleh = "Y" ]
then
  echo "GOOD: $bleh"
else
  echo "BAD: no."
fi
blah.sh:
Code:
#!/bin/sh

./bleh.sh

echo "enter blah: "
read blah

if [ $blah = "y" -o $blah = "Y" ]
then
  echo "GOOD: $blah"
else
  echo "BAD: no."
fi

echo "blah blah blah"
when running blah.sh manually, the steps go fine. it calls bleh, you enter y, it echos, it goes on to the rest of blah, you enter y, it goes on....

if you take out bleh.sh and do something like
echo y | ./blah.sh

it's also fine

but if bleh.sh is there (or if there are two read points in the file), then i can't pass two "y"s to the script to have one go to one and the second go to the next

echo y | (echo y | ./blah.sh) or anything like that, doesn't work. in fact, although nothing gets sent to the second read point, the second if -o block returns "blah.sh: line x: [: too many arguments"

i don't know if version matters in this case, but it's rhel 4

Last edited by glamiss; 05-01-2012 at 10:02 AM.
 
Old 05-01-2012, 11:26 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Have you tried
Code:
echo 'y
y' | ./blah.sh
Regards the error message, use [[ ]] instead of [ ]. It's easier to work with for reasons explained here.
 
1 members found this post helpful.
Old 05-01-2012, 01:35 PM   #3
glamiss
LQ Newbie
 
Registered: May 2012
Location: minneapolis
Distribution: rhel 3/4 (soon to add 5)
Posts: 9

Original Poster
Rep: Reputation: Disabled
excellent, that was it. thanks!
 
Old 05-02-2012, 01:32 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Glad it worked for you

Threads can be marked SOLVED via the Thread Tools menu.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Passing inputs to the script senthil1186 Linux - Server 2 08-30-2011 02:15 PM
[SOLVED] Run script from another with multiple user inputs and expect ! zoonose Linux - Newbie 2 06-05-2011 08:57 PM
[SOLVED] Passing multiple arguments in shell script dgs012 Linux - Newbie 7 12-11-2010 12:06 PM
Create BASH script to process multiple inputs on read davisbase Linux - Newbie 5 05-26-2010 11:57 PM
Is 'nice' inherited to child processes? e.g. bash script/php script that calls MySQL SirTristan Linux - Newbie 1 12-04-2008 12:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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
Open Source Consulting | Domain Registration