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 05-16-2017
mohtashims mohtashims is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 15 October 2017, 12:50 AM EDT
Posts: 779
Thanks: 204
Thanked 7 Times in 7 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; 05-16-2017 at 11:59 AM.. Reason: Corrected tags
Sponsored Links
    #2  
Old 05-16-2017
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 17 October 2017, 2:51 PM EDT
Location: Saskatchewan
Posts: 22,464
Thanks: 1,139
Thanked 4,259 Times in 3,933 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 (05-16-2017)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:08 AM.