Home > Archive > PERL Beginners > May 2007 > pass variable to another program
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
pass variable to another program
|
|
| Brian Volk 2007-05-17, 9:59 pm |
| Hello,
Is there a way to pass a variable from one program to another? I have a
web site that allows the user to set the time they would like to
download a file... The program uses the Linux "at" command and launches
another perl program that does the actual FTP download. I would like to
pass a parm variable (email address) from the web site, captured in the
first perl program to the second perl program. Is this possible?
First program uses this line to queue the job
system "/usr/bin/at $hour:$minute $tod today < /var/www/cgi-bin/images";
images is a text file containing the perl program that runs the FTP
download:
perl /var/www/cgi-bin/get_image_file.pl
Is there a way to pass a variable from program 1 to program 2?
Thanks for your help!!
Brian Volk
| |
| Andy Greenwood 2007-05-17, 9:59 pm |
| On 5/17/07, Brian Volk <BVolk@hpproducts.com> wrote:
> Hello,
>
>
>
> Is there a way to pass a variable from one program to another? I have a
> web site that allows the user to set the time they would like to
> download a file... The program uses the Linux "at" command and launches
> another perl program that does the actual FTP download. I would like to
> pass a parm variable (email address) from the web site, captured in the
> first perl program to the second perl program. Is this possible?
I don't know of a way to directly pass a variable from one script to
another. However, you could easily enough pass it in as a command line
argument. Call the second script like
perl /path/to/script2.pl variable
And in script two, do something like
my $argument = shift | die "no argument given";
I'm sure TIMTOWTDI though.
>
>
>
> First program uses this line to queue the job
>
>
>
> system "/usr/bin/at $hour:$minute $tod today < /var/www/cgi-bin/images";
>
>
>
>
> images is a text file containing the perl program that runs the FTP
> download:
>
>
>
> perl /var/www/cgi-bin/get_image_file.pl
>
>
>
> Is there a way to pass a variable from program 1 to program 2?
>
>
>
> Thanks for your help!!
>
>
>
> Brian Volk
>
>
>
>
>
>
>
>
--
--
I'm nerdy in the extreme and whiter than sour cream
| |
| Steve Bertrand 2007-05-17, 9:59 pm |
| Brian Volk wrote:
> Hello,
>
>
>
> Is there a way to pass a variable from one program to another? I have a
> web site that allows the user to set the time they would like to
> download a file... The program uses the Linux "at" command and launches
> another perl program that does the actual FTP download. I would like to
> pass a parm variable (email address) from the web site, captured in the
> first perl program to the second perl program. Is this possible?
If you can stand to temporarily store the data in a file, check out
Storable module.
Steve
| |
| Brian Volk 2007-05-17, 9:59 pm |
|
> -----Original Message-----
> From: Andy Greenwood [mailto:greenwood.andy@gmail.com]
> Sent: Thursday, May 17, 2007 12:51 PM
> To: Brian Volk
> Cc: beginners@perl.org
> Subject: Re: pass variable to another program
>
> On 5/17/07, Brian Volk <BVolk@hpproducts.com> wrote:
>
> I don't know of a way to directly pass a variable from one script to
> another. However, you could easily enough pass it in as a command line
> argument. Call the second script like
>
> perl /path/to/script2.pl variable
>
> And in script two, do something like
>
> my $argument = shift | die "no argument given";
>
> I'm sure TIMTOWTDI though.
>
[Brian Volk] That work great! Thanks. I just created the script file on the
fly and added the email param variable at the end.
print IMAGES "perl /var/www/cgi-bin/get_ftp_images.pl $email\n";
Thanks again.
Brian
| |
| yaron@kahanovitch.com 2007-05-17, 9:59 pm |
| Hi,
I think that you are looking for a serialization mechanism.
For that you can use the Storable module (http://search.cpan.org/~ams/Stora=
ble-2.16/Storable.pm)
All you need to do is to freeze the variable in the first process, send it =
by pipe and thaw it in the other process.
Yaron Kahanovitch
----- Original Message -----
From: "Brian Volk" <BVolk@HPProducts.com>
To: beginners@perl.org
Sent: 19:43:20 (GMT+0200) Asia/Jerusalem =D7=99=D7=95=D7=9D =D7=97=D7=9E=D7=
=99=D7=A9=D7=99 17 =D7=9E=D7=90=D7=99 2007
Subject: pass variable to another program
Hello,
=20
Is there a way to pass a variable from one program to another? I have a
web site that allows the user to set the time they would like to
download a file... The program uses the Linux "at" command and launches
another perl program that does the actual FTP download. I would like to
pass a parm variable (email address) from the web site, captured in the
first perl program to the second perl program. Is this possible?
=20
First program uses this line to queue the job=20
=20
system "/usr/bin/at $hour:$minute $tod today < /var/www/cgi-bin/images";
=20
images is a text file containing the perl program that runs the FTP
download:
=20
perl /var/www/cgi-bin/get_image_file.pl=20
=20
Is there a way to pass a variable from program 1 to program 2?
=20
Thanks for your help!!
=20
Brian Volk
=20
=20
=20
| |
| Madan Kumar Nath 2007-05-18, 4:01 am |
|
Hello,
passing data / ( or sharing data, information ) between two
processes can be done
1. Writing the content in one file from 1st process and then reading
from second process.
you can do it, using simple text file or using seriallization.
2. Second way is through sockets. Once program writes in a socket and
the other program
reads from socket ( tcp Ip or any other protocol).
Please do understand that programs run in diffrent space and can not
use the memory space
of other.
Hope this helps
Cheers
Madan
Brian Volk wrote:
>Hello,
>
>
>
>Is there a way to pass a variable from one program to another? I have a
>web site that allows the user to set the time they would like to
>download a file... The program uses the Linux "at" command and launches
>another perl program that does the actual FTP download. I would like to
>pass a parm variable (email address) from the web site, captured in the
>first perl program to the second perl program. Is this possible?
>
>
>
>First program uses this line to queue the job
>
>
>
>system "/usr/bin/at $hour:$minute $tod today < /var/www/cgi-bin/images";
>
>
>
>
>images is a text file containing the perl program that runs the FTP
>download:
>
>
>
>perl /var/www/cgi-bin/get_image_file.pl
>
>
>
> Is there a way to pass a variable from program 1 to program 2?
>
>
>
>Thanks for your help!!
>
>
>
>Brian Volk
>
>
>
>
>
>
>
>
>
>
--
MyselfThanx & Regards !!
from Madan
Interra Systems India Pvt. Ltd.
A10, Sec9,NOIDA Ph: 0120-2442273/4 Ext 137
visit my homepage
<file:///net/capri/export/home/madank/.homepage/index.html>
<file:///net/capri/export/home/madank/.homepage/index.html>
|
|
|
|
|