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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing arguments on command line or through application

Status
Not open for further replies.

siswjh

MIS
Dec 6, 2001
63
US
I have written a perl script that concatenates files together. Pass arguements to the script on the command line. This is the way it goes:

$inputdir = <STDIN>;

my question is can you have perl to do this instead:

$inputdir = $1

I know in bourne and korn you can. The reason why I ask is because we use appworx; It's a schduler that you can set prompts in, which will let you enter data like from the command line. It (appworx) will work if you have a script that will take values from $1....$9 and set these to variables. If I use <STDIN> it's not happening. I know this does really seem to be a perl problem but if there is a way to get standard input other than using <STDIN> it would be a quick easy fix for me.

Thanks
Jesse
 
I'm not wholly sure I understand what you are asking. I'm reading it to mean that what you want to do is run a script while passing it variables from the command line e.g.

myscript.pl variable1 variable2 etc

If that's what you want to do, then yes you can do it, as follows:

#!/usr/contrib/bin/perl
my $firstvar = $ARGV[0]; #variable1 above
my $secondvar = $ARGV[1]; #variable2 above
etc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top