pass the input to invoking script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting pass the input to invoking script
# 1  
Old 07-08-2008
pass the input to invoking script

How to pass the input to the execution script

ex: test1.sh contains

#! usr/bin/sh

read val
echo $val

test2.sh contains

#! /usr/bin/sh

./test1.sh

now I am calling test2.sh thro command line

and I want to pass the input to the script test1.sh from test2.sh ..I mean not from the command line
# 2  
Old 07-08-2008
Code:
#! /usr/bin/sh
 .  ./test1.sh

source test1.sh that is the leading dot surrounded by spaces.
# 3  
Old 07-08-2008
I want to pass the value from second script to first script ...so the first script is asking input from the command line ..so I want to suppress this and
I have to pass the input through second script?
# 4  
Old 07-08-2008
Code:
cat sample1

#!/usr/bin/ksh

#value1=90;
#value2=70;
if [ $1 -gt $2 ];
then
echo "$1 is normal"
else
echo "$2 is abnormal"
fi

cat sample2

#!/usr/bin/ksh

echo "Calling the first script"

. ./sample1 20 30

echo "called the script"

namish@france => ./sample2
Calling the first script
30 is abnormal
called the script
/home/intas/namish/shell

# 5  
Old 07-08-2008
Quote:
Originally Posted by namishtiwari
Code:
cat sample1

#!/usr/bin/ksh

#value1=90;
#value2=70;
if [ $1 -gt $2 ];
then
echo "$1 is normal"
else
echo "$2 is abnormal"
fi

cat sample2

#!/usr/bin/ksh

echo "Calling the first script"

. ./sample1 20 30

echo "called the script"

namish@france => ./sample2
Calling the first script
30 is abnormal
called the script
/home/intas/namish/shell

thanks for the suggestion ...but
ex:

cat sample1

#!/usr/bin/ksh

#value1=90;
#value2=70;

read val1
read val2

if [ $val1 -gt $val2 ];
then
echo "$val1 is normal"
else
echo "$val2 is abnormal"
fi

cat sample2

#!/usr/bin/ksh

echo "Calling the first script"

. ./sample1

echo "called the script"

now it will ask for the input for val1 and val2 ....thro command line ...instated of this ...the second script should read from the property file ...for the first script input

from here whts the logic to pass the value to val1 and val2 variable..
because I don't have permission to edit "sample1" script ..only I can call this script and do the manipulation from the other script.

Last edited by vastare; 07-08-2008 at 08:38 AM.. Reason: for proper explanation
# 6  
Old 07-09-2008
I got the answer for my dout...find the solution

cat sample1

#!/usr/bin/ksh

#value1=90;
#value2=70;

read val1
echo "Val1 =" $val1
read val2
echo "Val2 =" $val2

cat sample2

#!/usr/bin/ksh

echo "Calling the first script"

sh sample1 << EOF
1
2
EOF

echo "called the script"

Output of the sample2 script is
Val1 =1
Val2 = 2

...now my dout is I want to use comment in b/w Redirecting input
i.e

sh sample1 << EOF
#Value of first parm
1
#Value of second parm
2
EOF

but the string is taking as an argument ...how can I achieve this? Smilie

expert suggestion is required!!!! waiting for the reply ....

Last edited by vastare; 07-10-2008 at 02:29 AM..
# 7  
Old 07-10-2008
Could you pls give us some suggestion on my query?????
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How pass the input parameter to a file in the script ?

OS version: RHEL 6.7 myTextFile.txt file is referred within Script1.sh script, I only execute Script1.sh and I want the input variable to be passed inside myTextFile.txt . Any idea how I can do this ? $ cat script1.sh cat myTextFile.txt $ cat myTextFile.txt $1 Requirement1.... (4 Replies)
Discussion started by: kraljic
4 Replies

2. UNIX for Dummies Questions & Answers

invoking script

hi all, is there a way to run a script upon invoking an application . for eg if i click on mozilla i want a script to run , before runniing mozilla , maybe ask a password or something only then open mozilla (2 Replies)
Discussion started by: mithun1!
2 Replies

3. UNIX for Dummies Questions & Answers

how to pass input from c program to shell script?

Hello.. I am developing a Graphical User Interface using GTK. As part of our project I need to take inputs from GTK entries and pass those inputs to shell script and use them in shell script. The problem which struck me is only limited number of inputs are getting passed to shell script. For now... (14 Replies)
Discussion started by: kalyanilinux
14 Replies

4. Shell Programming and Scripting

Invoking a script

I am new to Unix. Could some tell me what are all the possible ways of invoking/executing a script, doesnt matter which shell you are in. Thanks (4 Replies)
Discussion started by: bobby1015
4 Replies

5. Shell Programming and Scripting

How to input a number in a web page and pass to a script?

I am working on an embedded linux router and trying to make a webpage where the user can input a desired number of CPE and have a script update that number on the router. I have a CLI where I can log in and type the following to change that number echo "20">/proc/net/dbrctl/maxcpe which then... (7 Replies)
Discussion started by: BobTheBulldog
7 Replies

6. Shell Programming and Scripting

Pass input and output file as parameter to awk script

Hi, i am new to awk. I am using csv2pipe script(shown below) BEGIN { FS=SUBSEP; OFS="|" } { result = setcsv($0, ",") print } # setcsv(str, sep) - parse CSV (MS specification) input # str, the string to be parsed. (Most likely $0.) # sep, the separator between the values. # #... (6 Replies)
Discussion started by: bhaskarjha178
6 Replies

7. Programming

How to pass C array as input to Shell script

Hi, In the below C code , i want to pass the array to a unix shel script. my script should called as ex myscript 1,2,3 #include <stdio.h> int main() { int a={1,2,3}; } Thanks, Arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

8. Solaris

How to use Secure Shell (SSH) to pass results back to invoking machine

Hi, I am running a script from a client machine X which does "SSH" to around 100 other machines in a farm and invokes a local script on each of those machines. Local script localscript.sh on each of those 100 target machines, does some machine specific function like fetch the specific machine's... (1 Reply)
Discussion started by: waavman
1 Replies

9. Shell Programming and Scripting

pass input arguements to DB2 SQL script

Hi all, I have a shell script which invoke a sql script using command db2 -tf /home/me/db_housekeep.sql -z /home/me/db_housekeep.log however, this mentioned sql script requires several input arguments, I wonder if one can pass variables from shell script to sql script? thanks! (0 Replies)
Discussion started by: mpang_
0 Replies

10. Shell Programming and Scripting

read a file as input and pass each line to another script

Hi, I am trying to write a ftp script which will read a file for filenames and ftp those files to another server. Here's my ftp script, but it's scanning the current directory for file names. My question is how can I pass multiple files (these files will have the name of data files that need to... (0 Replies)
Discussion started by: sajjad02
0 Replies
Login or Register to Ask a Question