Passing data arguments via command line

Sorry, let's try that again with a sensible subject line -- Mo

========

Hi all,

This is a very dim question, but hey, this is a beginners' list so I hope 
you'll forgive me.

I want to be able to pass variable data arguments to my perl script from an 
outside application by calling a command line that's something along the 
lines of:

perl myscript.pl "data1" "data2 "data3"

(a) is it possible to pass data arguments via the command line in this way?

(b) inside the script I want to assign them to variables -- but how do I 
reference them? Do they count as being on STDIN or something?

Thanks for your help,

best,

Mo





Mo Holkar
Undying King Games
mo@ukg.co.uk
http://www.ukg.co.uk

0
mo
4/24/2001 11:09:28 AM
perl.beginners 29388 articles. 4 followers. Follow

3 Replies
787 Views

Similar Articles

[PageSpeed] 35
Get it on Google Play
Get it on Apple App Store

> perl myscript.pl "data1" "data2 "data3"
>
> (a) is it possible to pass data arguments via the command line in this
way?

Yes, indeed.  Anything that is passed to your program in this way will be
stored in the array, @ARGV.  You can access the first argument with
$ARGV[0], the second with $ARGV[1], and so on.

> (b) inside the script I want to assign them to variables -- but how do I
> reference them? Do they count as being on STDIN or something?

You can assign them at the beginning of your script usign the following:

my @theArguments = @ARGV   #all of them in an array

-or-

my ($username, $password, $logfile, $filename) = @ARGV
     # Expect 4 arguments
     # Ignore the rest for now


0
steve
4/24/2001 11:52:02 AM
On Tue, Apr 24, 2001 at 12:09:28PM +0100, Mo Holkar / UKG wrote:

> perl myscript.pl "data1" "data2 "data3"
> 
> (a) is it possible to pass data arguments via the command line in this way?

Yes.

> (b) inside the script I want to assign them to variables -- but how do I 
> reference them? Do they count as being on STDIN or something?

You will find them in the @ARGV array in the same order they were passed
in.  You may access this as any other array.

perldoc perlvar
perldoc perldata

-- 
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
0
paul
4/24/2001 12:00:13 PM
On Tue, Apr 24, 2001 at 06:52:02AM -0500, Steve Neu wrote:
> > perl myscript.pl "data1" "data2 "data3"
> >
> > (a) is it possible to pass data arguments via the command line in this
> way?
> 
[snip options] 
> -or-
> 
> my ($username, $password, $logfile, $filename) = @ARGV
>      # Expect 4 arguments
>      # Ignore the rest for now

Note, of course, that this does not actually *remove* the first four
arguments from @ARGV.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I go where I will and I do what I can" - Henry Fool
0
dha
4/24/2001 9:16:00 PM
Reply:

Similar Artilces:

How to pass command line arguments to an extension using a command line on MacOS
I am developing an extension that processes some command line options. I want to invoke the Firefox from a command line like this: > ...../firefox -myarg1 -myarg2 I am running into a problem on Mac OS. When I run such command when there is no FireFox running it works fine. However if I run the command again I get an error saying that there is already an instance of Firefox running and only one instance can run at a time (paraphrasing here). I have tried to use the -remote option but no luck. Does anyone know how to solve this problem? Does anyone know if invoking of chatzill...

How to pass command line arguments to an extension using a command line on MacOS?
I am developing an extension that processes some command line options. I want to invoke the Firefox from a command line like this: > ...../firefox -myarg1 -myarg2 I am running into a problem on Mac OS. When I run such command when there is no FireFox running it works fine. However if I run the command again I get an error saying that there is already an instance of Firefox running and only one instance can run at a time (paraphrasing here). I have tried to use the -remote option but no luck. Does anyone know how to solve this problem? Does anyone know if invoking of chatzill...

Passing command line arguments
------_=_NextPart_001_01C54075.E7225C28 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I have a script that is reading input from ARGV. The script is being passed a file name as follows: =20 datefile.pl c:\program files\IBM\SQLLIB\DB2\db2diag.log =20 The problem I am running into is that the space is not recognized in the argument. All that I get passed to is is c:\program . How do I get the rest of the argument. Below is a portion of the script. Thanks. =20 #*********************************************** # check i...

How to pass string in command line argument.
------=_Part_34745_22223991.1161859678592 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline hi , I want to pass a command argument to perl script with double quotes (" ); below is my scenario my xml file is something like this .. <root> <reff> <var1>123</var1> <var2>this is my name</var2> </reff> <reff> <var1>234</var1> <var2>this is others name </var2> </reff> </root> my perl script...

Passing table name as (command line) argument
Any way to pass the name of a table to be processed via an argument either from a command line or in a composite report. We have several tables that are processed by otherwise identical reports/cross-tabs. Rick; If you have PowerBuilder at your site you could do it by: 1) In PB, create a global function(GF). In that function, use the "GetContextKeywords" method to access DOS environment variables. Return a "String" of the DOS variable you wish to locate. 2) In PB, modify the report Window class in the IMStyle.pbl library that IM uses to build the E...

Can I pass dynamic command-line arguments?
Is there a way to pass dynamic command-line arguments when I run the .wdk file? Shoshana Kalson ...

Passing command line arguments to XUL application
Hi all, I am new to XUL. I am trying to port a MFC web application to XUL. I have gone through the tutorial for creating XUL-based browser application (launched with XULRunner.exe) without using any C++ code. All the code is in JavaScript. One problem I am having is to retrieve the command line arguments that I pass to the XUL application. In the MFC version, I would execute something like: myApp.exe -x 200 -y 400 -z "long string argument" So in my XUL-based application I tried the following: XULRunner.exe myApp -x 200 -y 400 -z "long string arg...

Passing command line arguments to a XUL application? How?
I have an application which is started on client hosts using "firefox -chrome chrome://idesk/chrome". I am looking for a solution to pass an additional URL as argument to the application where the application get some further UI informations from. This since URL is specific to the client I can not hard-code the URL into the XUL application. I played with reading the information from a local configuration file in the file-system (which works) but the client application can run on any operating system and being installed in any location..so there is no fixed location I can...

Pass Parameter to Interactive SQL via Command Line
Is there a way to pass a parameter to the Interactive SQL via the command line? The command line looks like: dbisql -c "uid=dba;pwd=sql;dbf=D:\Temp\%1\meteroneany.db" D:\Temp\subscribe.sql I call a .bat file and pass the %1 parameter to the dbisql command line. The %1 parameter is the mluser I wish to subscribe. The dbisql command also calls the subscribe.sql file. The subscribe.sql looks like: parameters mluser; create synchronization user {mluser} create synchronization subscription to meteroneremote for {mluser} Currently I have to manually enter the mlus...

Controlling date formats on date parameters passed in via command line
SA10.0.1.3784 Windows XP Pro Windows Server 2003 How can I pass in a date parameter in the format of mm/dd/yy from the command prompt and get it to be recognized by the database if the database is storing dates in the format of yyyy-mm-dd? I've created a batch extract file for a customer and it works perfectly except they don't like entering the date parameters in the yyyy-mm-dd format (spoiled Americans!) When the dates are entered with the slash format it throws an error that it can't convert it to a timestamp. I've tried using the DateFormat function but ...

PB 10.5 Problems Building via Command Line Arguments
Has anyone had problems building using the command line switches in PB 10.5? I have a workspace and target that I can deploy from manually launching the IDE with no problems. If I try to do it using the command line switches (which is what our automated build process does) it opens the IDE, briefly displays the systemtree with drive listings instead of the workspace and target and then exits writing this to the log file: ---------- Deploy: Deploy of workspace build ---------- Deploying project myapp ---------- Done Deploying project myapp ---------- Finished Deploy of workspace...

Providing command-line arguments to tests run via 'prove'
Let's suppose that I have a suite of test files which I customarily run with 'prove': prove t/*.t .... where the tests in t/ are: alpha.t beta.t gamma.t Let's further suppose that each of these three tests simulates the operation of a Perl program which is normally called with command-line arguments or options: perl myperlprogram.pl --option1 --option2 arg1 arg2 I know in advance that some of my users call myperlprogram.pl with options and some don't -- but I don't know what values they provide for those options. I would lik...

How to pass 2 command arguments for a single command?
Hi I need 2 command arguments for edit . I tried to Pass like CommandArgument='<%# Eval("Path") +'|'+Eval("imageTypeId") this and in the .csstring arg = Convert.ToString(e.CommandArgument); Response.Write(arg);string[] splitarg = arg.Split('|'); Response.Write(splitarg[0]); Its not working. can anyone help me?  I'm using XmlDatasource try this CommandArgument='<%# XPath("Name").ToString() + "|" + XPath("Name").ToString()%>' Hosam Kamel Remember to click on Mark as answer on the p...

Command Line arguments
I am new to Power++ so it could be a rather silly question.... In my application I would like to read the number of command line arguments and the arguments itself, ie like argc and argv of typical C programs. Sunitha http://www.orbit.org/power/n_november97.html#11 Check out the above link... Hope this helps Pat Sunitha Chamarti wrote in message <35EDB5E7.820559FB@sybase.com>... >I am new to Power++ so it could be a rather silly question.... > >In my application I would like to read the number of command line >arguments and the arguments itself, ie l...

Web resources about - Passing data arguments via command line - perl.beginners

Argument (linguistics) - Wikipedia, the free encyclopedia
In linguistics , an argument is an expression that helps complete the meaning of a predicate . Most predicates take one, two, or three arguments. ...

Arguments in Officer William G. Porter's appeal will be heard in March - Baltimore Sun
An aggressive timetable initially set for the trials of the six Baltimore police officers charged in the arrest and death of Freddie Gray has ...

"And beyond the constitutional argument, adults younger than age 25 are just as entitled to the tools ...
"Indeed, 18-to-24-year-old women are especially likely to be targets for rape, but more broadly 18-to-24-year-olds are especially likely to be ...

The News Notices the News: Clinton's Electability Argument "Flies in the Face" of Polling Data
Bernie Sanders says he's the Democrats' most electable candidate. Watch more: http://on.msnbc.com/1RiaBmh Posted by Morning Joe on Monday, January ...

Identifying the Most Common Pitfalls in Arguments on the Path to Logical Reasoning
... from arguing well. Common sense, after all, is not that common. Fallacies can either be formal or informal. We can see the first in the argument's ...

Leonardo DiCaprio Declares ‘Argument Over’ On Global Warming
'Anyone that doesn't believe that ... doesn't believe in science'

Jaguars Beat Writer And Chris Clemons Finish The Season With An Argument
The Jacksonville Jaguars got walloped by the Houston Texans today to end their season at 5-11. The team lost their playoff chances a few weeks ...

Defense finishing closing arguments in San Francisco Chinatown murder, racketeering trial
... a man charged with murder and racketeering in a San Francisco Chinatown organized crime investigation is expected to finish its closing arguments. ...

Closing Arguments Underway in San Francisco Chinatown Trial
Closing arguments underway in racketeering, murder trial of San Francisco Chinatown defendant

Public-sector unions face crucial argument before Supreme Court
The Supreme Court on Monday will consider eliminating a pillar of public-sector union strength in more than 20 Democratic-leaning states: the ...

Resources last updated: 1/14/2016 9:58:12 PM