Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
cat sample1#!/usr/bin/ksh
#value1=90;
#value2=70;read val1
echo "Val1 =" $val1
read val2
echo "Val2 =" $val2
read passwordcat sample2
#!/usr/bin/ksh
echo "Calling the first script"
sh sample1 << EOF
1
2
nav
EOFecho "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.esh sample1 << EOF
#Value of first parm
1
#Value of second parm
2
EOFbut 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

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
2Would you think it proper to place comments in datafile.txt:
#Value of first parm
1
#Value of second parm
2and expect the shell to not treat the comments as input?
You are forced to place comments outside the here document definition.

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 passwordso 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

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.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |