Computing.Net > Forums > Solaris > Passing args from 1script to anothr

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Passing args from 1script to anothr

Reply to Message Icon

Name: vastare
Date: July 10, 2008 at 03:07:45 Pacific
OS: SunOS
CPU/Ram: 32
Product: sun4u sparc SUNW,Sun-Fire
Comment:


cat sample1

#!/usr/bin/ksh

#value1=90;
#value2=70;

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

cat sample2

#!/usr/bin/ksh

echo "Calling the first script"

sh sample1 << EOF
1
2
nav
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 comment string is taking as an argument ...how can I achieve this?

b/w the EOF the I want to use comments ...

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

Thanks in advance,
-----------
Vastare



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: July 10, 2008 at 12:57:23 Pacific
Reply:

Sorry, but Unix here documents don't work that way. Every thing between the first EOF and the second EOF is considered as input.

All a here document does is redirect input. Consider redirecting input from a file to sample1:

sample1 < datafile.txt

where datafile.txt contains this:

1
2

Would you think it proper to place comments in datafile.txt:

#Value of first parm
1
#Value of second parm
2

and expect the shell to not treat the comments as input?

You are forced to place comments outside the here document definition.


0

Response Number 2
Name: vastare
Date: July 10, 2008 at 22:46:44 Pacific
Reply:

Thank you so much for kind response....

here my one more problem is

Script one is reading password from the user...When user enter, the wont be visible to the user....

cat sample1

#!/usr/bin/ksh

echo "enter the username:\c"
read username
echo "\nenter the passowrd:\c"
read password

so the output of sample1.sh is

enter the username: vastare
enter the passowrd: (here wen i enter the password ...password wont be visible)

I am calling sample1 script in script2

cat sample2

#!/usr/bin/ksh

echo "Calling the first script"

sh sample1 << EOF
vastare
nav
EOF
echo "called the script"

Output of the sample2 script is

Calling the first script
enter the passowrd:
( here im passing password info from 2nd script ...and its not taking ...only the user name will take ..

how can I pass the password info to 1st script

Need your valuable suggestion here

Thanks in advance,
-----------
Vastare


0

Response Number 3
Name: nails
Date: July 13, 2008 at 13:49:15 Pacific
Reply:

I'm not having any trouble with your example scripts.

If I were you, I'd get rid of the call to sh:

sample1 << EOF
vastare
nav
EOF
echo "called the script"

There is no reason for it. On most systems, 'sh sample1' would be a call to the bourne shell.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Passing args from 1script to anothr

auto file transfer from unix to xp www.computing.net/answers/solaris/auto-file-transfer-from-unix-to-xp/4407.html

UUCP from Solaris to Windows www.computing.net/answers/solaris/uucp-from-solaris-to-windows/4222.html

changed boot device from a: to cdrom www.computing.net/answers/solaris/changed-boot-device-from-a-to-cdrom/1700.html