Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass arguments to another Perl script

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
US
Have a Perl script that has a few variables and then at the end does an ssh to a server and runs another script.

For a test script on the remote server I'm doing:
Code:
#!/usr/bin/perl
eval "$ARGV[0]";
print "$option1 $option2 $option3\n";

But it's not printing those set in the originating script on the primary server.
 
Code:
#!/usr/bin/perl
eval "$ARGV[0]";
print "$option1 $option2 $option3\n";

For this to work, the contents of $ARGV[0] should be some perl code that sets $option1, $option2, and $option3. For ex:

Code:
my $code = "\$option1 = \"value 1\";";
eval "$code";
print "$option1\n";

Note that in $code, all the $'s are escaped; because they need to be literal $ symbols for eval.

Kirsle.net | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Thanks. I figured out my problem when I was looking at it. It was a long day. Time away was the fix. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top