How to pass a variable from a shell script to another shell script...

How to pass a variable from a shell script to another shell script...

Post by v.nagasriniva » Fri, 03 Jan 2003 14:40:38



Hi,
         I have written a shell script 1............and internally its
calling another shell script 2........input to  redhat specific
chkconfig command... which executes and builds links in bootstartup
scipt directories (rc.d).

Actually i needs to pass a variable $DIRECTORY  of my command available
( can hard code but i am
setting it in the 1st script) to the 2nd script how to pass that... As
the setting is happening before the calling of
shell script2, i just tried like putting  echo "$DIRECTORY" into the 2nd
shell script, which is not working is there
a way to get the functionality.

shellscript1:
#!/bin/sh
---------
---------
---------
DIRECTORY="/sbin/ntp"
---------
---------
/sbin/chkconfig "shellscript2"
---------

shellscript2:
#!/bin/sh
-------
echo "$DIRECTORY"     <------put to see whether getting the value here
or not..

$DIRECTORY   -c ntp.conf          <------if it is so ,  i could use like
this.................

thanks,
srinivas.

--
office ph: 091-40-3607619

 
 
 

How to pass a variable from a shell script to another shell script...

Post by ty » Fri, 03 Jan 2003 14:41:05


try
export DIRECTORY
in shellscript1

ie

#!/bin/sh
DIRECTORY=blah
export DIRECTORY
/sbin/chkconfig shellscript2

hth
ty


Quote:

> Hi,
>          I have written a shell script 1............and internally its
> calling another shell script 2........input to  redhat specific
> chkconfig command... which executes and builds links in bootstartup
> scipt directories (rc.d).

> Actually i needs to pass a variable $DIRECTORY  of my command available
> ( can hard code but i am
> setting it in the 1st script) to the 2nd script how to pass that... As
> the setting is happening before the calling of
> shell script2, i just tried like putting  echo "$DIRECTORY" into the 2nd
> shell script, which is not working is there
> a way to get the functionality.

> shellscript1:
> #!/bin/sh
> ---------
> ---------
> ---------
> DIRECTORY="/sbin/ntp"
> ---------
> ---------
> /sbin/chkconfig "shellscript2"
> ---------

> shellscript2:
> #!/bin/sh
> -------
> echo "$DIRECTORY"     <------put to see whether getting the value here
> or not..

> $DIRECTORY   -c ntp.conf          <------if it is so ,  i could use like
> this.................

> thanks,
> srinivas.

> --
> office ph: 091-40-3607619


 
 
 

1. Passing a variable between shell script and perl script

I have a ksh shell script that sets a variable by taking a date input
(format CCYYMMDD) from the console and uses it to do all sorts of
stuff. The last thing the script does is to call a perl script. What I
am trying to do is to pass this date into the perl script but I don't
seem to be having any success and the published wisdom is confusing me
even more. Can someone straighten me out please?

TIA

John

2. tochiba librettos

3. Passing a variable from a Perl script to a shell script

4. Run Levels ???

5. How do you pass a value from a shell script into a sqlplus script?

6. Kernel compile problems...

7. handling SIGINT in shell scripts when executing another shell script.

8. atrun?

9. Q: How can I have a shell script call another shell script...

10. Shell script invoking other shell scripts

11. Convert Bash shell script to Korn shell script

12. Shell Script Help (C-Shell Script)

13. Shell script acting as interactive shell - $0 not script name??