Perl sys.argv issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl sys.argv issue
# 1  
Old 05-16-2017
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 12:59 PM.. Reason: Corrected tags
# 2  
Old 05-16-2017
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.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

2. Shell Programming and Scripting

Wildcarding in a Perl @ARGV Context?

Hello folks! While "sedding" about again, I ran into this little conundrum du jour:#!/usr/bin/perl use strict; use warnings; use diagnostics; @ARGV = ('./afile.dat', './*.txt'); $^I = ''; while (<>) { s/Twinkies/Dinner/g; print; }When run, perl complains,...but, of... (2 Replies)
Discussion started by: LinQ
2 Replies

3. Shell Programming and Scripting

Wildcarding in a Perl @ARGV Context?

Hello folks! While "sedding" about again, I ran into this little conundrum du jour:#!/usr/bin/perl use strict; use warnings; use diagnostics; @ARGV = ('./afile.dat', './*.txt'); $^I = ''; while (<>) { s/Twinkies/Dinner/g; print; }When run, perl complains,...but, of... (1 Reply)
Discussion started by: LinQ
1 Replies

4. Shell Programming and Scripting

Match in perl not working with ARGV

Hi , I need to match module data_tx_dig ( I tried matching ~m/module(\s+)ARGV(\s+)\(/ --> (generic code)but is not working.The same is able to match when i provide hardcoded value instead of passing from the command line. ~m/module(\s+)data_tx_dig(\s+)\(/ -->(hardcoded code).Please help me... (8 Replies)
Discussion started by: dll_fpga
8 Replies

5. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

6. Shell Programming and Scripting

Perl using modules CPU SYS and ENV

I have a project on which I have to use cpuinfo to get model name, number of cpus and bogomips.. for sys I need the uptime, total ram and from env I need the HOSTNAME.. from CMD ouputs i need the eth0-ip and .df.. The problem is that those modules have to be call from a subroutine and I have to... (0 Replies)
Discussion started by: thiedi16
0 Replies

7. Programming

ARGV help in C

Hi, Can somehelp help how to list file in a dir? (5 Replies)
Discussion started by: Learnerabc
5 Replies

8. Shell Programming and Scripting

how to include slashes "/" in @ARGV (Perl)

Hello I have simple script that will accept as arg string like this : ".../foo/blah/,.../.../foo1/,.../blah" now perl automatically removes the slashes "/" , I can't escape the slashes in the input I have to control on it so how can I force perl to not touch this slashes? Thanks ... (5 Replies)
Discussion started by: umen
5 Replies

9. UNIX for Dummies Questions & Answers

Solaris 10 sys-unconfig issue (brand new user)

ok, Newbie here..... I just installed this solaris 10 for a class I'm taking. We couldn't figure out how to change the IP so we were told to just do it from the sys-uncofig process. Well, after I did that, I lost the GUI witch isn't all that bad cuz I want to learn the cli anyways, but I keep... (1 Reply)
Discussion started by: moesays
1 Replies

10. Shell Programming and Scripting

Perl: Getting $ARGV's to operate like while(<>)

I have a script that asks a bunch of questions using the following method for input: print "Name:"; while(<>){ chomp; $name=$_; } So for example, if the questions asked for name, age, & color (in that order)... I want to be able to easily convert $ARGV into the input expected by... (2 Replies)
Discussion started by: jjinno
2 Replies
Login or Register to Ask a Question