Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Perl sys.argv issue

Shell Programming and Scripting


Tags
perl

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
mohtashims mohtashims is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 25 May 2017, 8:12 AM EDT
Posts: 699
Thanks: 179
Thanked 6 Times in 6 Posts
Tools Perl sys.argv issue

I am running a perl script and reading the arguments passed to the script as below..... resembles more arguments.

Code:
java weblogic.WLST /web/update.py 34 56 ....

I am trying to print the arguments passed to the update.py script as below


Code:
    for arg in sys.argv:
        print "other args:", arg

Output:
Quote:
/web/update.py
34
56
....
I do not want the script name /web/update.py to be printed in the loop only the arguments passed to the .py should be printed i.e 34 & 56 ...

Can you please suggest a solution ?

Last edited by rbatte1; 1 Week Ago at 11:59 AM.. Reason: Corrected tags
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 26 May 2017, 4:17 PM EDT
Location: Saskatchewan
Posts: 22,183
Thanks: 1,092
Thanked 4,174 Times in 3,861 Posts
It is part of argv, though, by about 50 years of tradition. Do a loop from 1 to len(sys.argv) instead to avoid it.
The Following User Says Thank You to Corona688 For This Useful Post:
mohtashims (1 Week Ago)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Wildcarding in a Perl @ARGV Context? LinQ Shell Programming and Scripting 2 11-03-2014 04:10 PM
Wildcarding in a Perl @ARGV Context? LinQ Shell Programming and Scripting 1 10-31-2014 05:33 PM
Match in perl not working with ARGV dll_fpga Shell Programming and Scripting 8 11-08-2013 02:34 PM
O argv, argv, wherefore art thou argv? alister UNIX for Advanced & Expert Users 9 05-09-2013 08:56 PM
Perl: Getting $ARGV's to operate like while(<>) jjinno Shell Programming and Scripting 2 07-19-2007 08:40 AM



All times are GMT -4. The time now is 07:36 AM.