calling a script with arguments

Discussion in 'Perl Misc' started by jpw, Jul 25, 2007.

  1. jpw

    jpw Guest

    I have a script that creates and XML record and then posts it to a
    url. I'd like to be able to build the XML record separately and just
    "pass" it to the script. The script needs to be excuted at the shell
    prompt. So, I'd like to be able to execute: ./myscript
    <path&filename to xml file>.

    How, from within, the script to I get the xml file? In other
    programming environments, I have used the @sentence command which
    provides the script with the entire line it was executed with.
     
    jpw, Jul 25, 2007
    #1
    1. Advertising

  2. jpw

    -berlin.de Guest

    jpw <> wrote in comp.lang.perl.misc:
    > I have a script that creates and XML record and then posts it to a
    > url. I'd like to be able to build the XML record separately and just
    > "pass" it to the script. The script needs to be excuted at the shell
    > prompt. So, I'd like to be able to execute: ./myscript
    > <path&filename to xml file>.
    >
    > How, from within, the script to I get the xml file? In other
    > programming environments, I have used the @sentence command which
    > provides the script with the entire line it was executed with.
    >


    perldoc perlvar, look for @ARGV.

    Anno
     
    -berlin.de, Jul 25, 2007
    #2
    1. Advertising

  3. jpw wrote:
    > I have a script that creates and XML record and then posts it to a
    > url. I'd like to be able to build the XML record separately and just
    > "pass" it to the script. The script needs to be excuted at the shell
    > prompt. So, I'd like to be able to execute: ./myscript
    > <path&filename to xml file>.
    >
    > How, from within, the script to I get the xml file?


    perldoc -f open

    > In other
    > programming environments, I have used the @sentence command which
    > provides the script with the entire line it was executed with.


    Are you just looking for @ARGV (details see perldoc perlvar)?

    jue
     
    Jürgen Exner, Jul 25, 2007
    #3
  4. jpw

    Paul Lalli Guest

    On Jul 25, 10:13 am, jpw <> wrote:
    > I have a script that creates and XML record and then posts it to a
    > url. I'd like to be able to build the XML record separately and just
    > "pass" it to the script. The script needs to be excuted at the shell
    > prompt. So, I'd like to be able to execute: ./myscript
    > <path&filename to xml file>.
    >
    > How, from within, the script to I get the xml file? In other
    > programming environments, I have used the @sentence command which
    > provides the script with the entire line it was executed with.


    Anno and Jue already told you that you're looking for the @ARGV array,
    but I am *very* curious what you mean by "the @sentence command".
    There is no such command. @sentence is a user-defined array that has
    no special meaning whatsoever. Can you please explain what you meant
    by this?

    Paul Lalli
     
    Paul Lalli, Jul 25, 2007
    #4
  5. jpw

    jpw Guest

    On Jul 25, 10:37 am, Paul Lalli <> wrote:
    > On Jul 25, 10:13 am, jpw <> wrote:
    >
    > > I have a script that creates and XML record and then posts it to a
    > > url. I'd like to be able to build the XML record separately and just
    > > "pass" it to the script. The script needs to be excuted at the shell
    > > prompt. So, I'd like to be able to execute: ./myscript
    > > <path&filename to xml file>.

    >
    > > How, from within, the script to I get the xml file? In other
    > > programming environments, I have used the @sentence command which
    > > provides the script with the entire line it was executed with.

    >
    > Anno and Jue already told you that you're looking for the @ARGV array,
    > but I am *very* curious what you mean by "the @sentence command".
    > There is no such command. @sentence is a user-defined array that has
    > no special meaning whatsoever. Can you please explain what you meant
    > by this?
    >
    > Paul Lalli


    Thank you for the replies. While ARGV does provide me the string
    value of the command line, as opposed to the actual "content" of the
    xml file. Presumably I would then have to *read* the file in to a
    variable to then be posted to the url. Incidently, I don't know how
    to do that either.

    Regarding @sentence. Sorry for the confusion. I should have just
    said "commandline arguments". The reference to @sentence was merely
    an example from another programing language (namely, Unidata). It's
    has the same function as ARGV in PERL.

    On to research reading files and assigning them to an array variable
    (any knowledge of this?)


    John
     
    jpw, Jul 25, 2007
    #5
  6. jpw

    Paul Lalli Guest

    On Jul 25, 11:16 am, jpw <> wrote:

    > Thank you for the replies. While ARGV does provide me the string
    > value of the command line, as opposed to the actual "content" of the
    > xml file. Presumably I would then have to *read* the file in to a
    > variable to then be posted to the url. Incidently, I don't know how
    > to do that either.


    Jue gave you that answer too.

    perldoc -f open
    perldoc -f readline
    perldoc perlop

    Paul Lalli
     
    Paul Lalli, Jul 25, 2007
    #6
  7. jpw wrote:
    > While ARGV does provide me the string
    > value of the command line, as opposed to the actual "content" of the
    > xml file. Presumably I would then have to *read* the file in to a
    > variable to then be posted to the url. Incidently, I don't know how
    > to do that either.


    http://perldoc.perl.org/perlintro.html

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Jul 25, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Navaneeth
    Replies:
    4
    Views:
    553
    Kenny McCormack
    Nov 20, 2010
  2. Yogi
    Replies:
    1
    Views:
    434
    Peter Makholm
    Sep 13, 2012
  3. PEnergy
    Replies:
    2
    Views:
    89
    Michael Torrie
    Apr 16, 2013
  4. Florian Lindner

    Problem calling script with arguments

    Florian Lindner, Oct 15, 2013, in forum: Python
    Replies:
    0
    Views:
    83
    Florian Lindner
    Oct 15, 2013
  5. Michael Speer

    Re: Problem calling script with arguments

    Michael Speer, Oct 15, 2013, in forum: Python
    Replies:
    0
    Views:
    94
    Michael Speer
    Oct 15, 2013
Loading...

Share This Page