473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

cmdline args to a piped python prog

leo
hi there

a python file can evaluate cmdline arguments like

python myprog.py arg1 arg2 arg3...

when i feed python with my program via terminal input like

cat myprog.py | python

how can i then specifiy the cmdline arguments arg1 arg2 arg3...?

thanks a lot, leo

ps: wondering why i ask? -- emacs calls python code from abuffer always in
the latter way.

Jul 18 '05 #1
2 1410
>>>>> "leo" <ha******@noospaam.myrealbox.com> (L) wrote:

L> hi there
L> a python file can evaluate cmdline arguments like

L> python myprog.py arg1 arg2 arg3...

L> when i feed python with my program via terminal input like

L> cat myprog.py | python

L> how can i then specifiy the cmdline arguments arg1 arg2 arg3...?

You could say cat myprog.py | python - arg1 arg2 arg3
Then sys.argv[1:] contains the arguments.

By the way cat myprog.py | python * is equivalent to python * < myprog.py
No need for cat.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.***********@hccnet.nl
Jul 18 '05 #2
leo
thanks a lot, piet.

leo

"Piet van Oostrum" <pi**@cs.uu.nl> wrote in message
news:wz************@ordesa.cs.uu.nl...
>> "leo" <ha******@noospaam.myrealbox.com> (L) wrote:


L> hi there
L> a python file can evaluate cmdline arguments like

L> python myprog.py arg1 arg2 arg3...

L> when i feed python with my program via terminal input like

L> cat myprog.py | python

L> how can i then specifiy the cmdline arguments arg1 arg2 arg3...?

You could say cat myprog.py | python - arg1 arg2 arg3
Then sys.argv[1:] contains the arguments.

By the way cat myprog.py | python * is equivalent to python * < myprog.py
No need for cat.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.***********@hccnet.nl

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
I am very new to Python and read the docs section about having python run commands from the command line. I have been successful with: python -c "print 'Hello'" It prints Hello In the...
23
by: Spiffy | last post by:
hello, i'm fairly new to python programming and programming in general, but i have written a python prog that creates a MIDI file (.mid) and I want to be able to play it from another prog which is...
5
by: Didier C | last post by:
Hi! I was wondering if we can pass some arguments to system("cmdline")? E.g in Perl, we can do something like: $dir="/home/cypher"; system("ls $dir"); which would instruct Perl to do an...
0
by: Nx | last post by:
Suse Linux 9.2 64 Python 2.3 64 bit Python 2.4 32 bit My question is : I have a python prog which is installed for python 2.3 but I need some variables filled with data, which I only can...
2
by: abhinav | last post by:
//A CRAWLER IMPLEMENTATION please run this prog. on the shell and under the control of debugger when this prog. is run normally the prog. does not terminate .It doesn't come out of the cond. if...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
9
by: Katie Tam | last post by:
I am new to this filed and begin to learn this langague. Can you tell me the good books to start with ? Katie Tam Network administrator http://www.linkwaves.com/main.asp...
1
by: =?iso-8859-1?b?Suly6W1pZQ==?= | last post by:
Hello everyone, Here's the deal : I get from a coworker some mails with a ZIP file attached. I've created an email aliases that resends the mail to a program using the smrsh mechanism. My...
11
by: HowardL | last post by:
Hi, I would like to be able to either pipe data into my prog from stdin or get data from a file. If I try to check by using if( Console.In.Peek() != -1 ) { Console.WriteLine("GOT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.