Passing a variable between shell script and perl script

Passing a variable between shell script and perl script

Post by John Drakes » Wed, 25 Aug 2004 17:47:27



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

 
 
 

Passing a variable between shell script and perl script

Post by Bit Twiste » Wed, 25 Aug 2004 21:06:47



Quote:> 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?

Either use $ENV in the perl script or pass the variable as an argument when
calling the perl script.

 
 
 

Passing a variable between shell script and perl script

Post by swim learni » Fri, 27 Aug 2004 05:31:52



> 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

Here is a one-line perl script, test.pl:

print $ARGV[0], "\n";

Here is how to call it from a shell script:

mydate="20040925 is my date"
/usr/bin/perl test.pl "$mydate"

Here is the output:

20040925 is my date

 
 
 

Passing a variable between shell script and perl script

Post by John Drakes » Fri, 27 Aug 2004 17:28:28


For an old thicko like me there is often far too much info available.
Thank goodness there are the shining lights out there prepared to help
cut through the chaff. Many thanks guys.

John



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

> Here is a one-line perl script, test.pl:

> print $ARGV[0], "\n";

> Here is how to call it from a shell script:

> mydate="20040925 is my date"
> /usr/bin/perl test.pl "$mydate"

> Here is the output:

> 20040925 is my date