LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2005, 03:52 AM   #1
goestin
Member
 
Registered: Nov 2004
Location: Netherlands (east)
Distribution: debian, suse, novell linux desktop
Posts: 81

Rep: Reputation: 15
python problem...


hi all,
i've a problem in python which i thought what would be easily to solve but i can't find any solution.

ok, my problem is this. In bash you can pass arguments when you start a program like:

goestin@JustinuX:/$ ./script.sh 127.0.0.1
where "127.0.0.1" is a variable stored in $1

how is the same thing possible in python? so i can use this:

goestin@JustinuX:/$ ./script.py 127.0.0.1

is there also a default variable where "127.0.0.1" is stored now?


thanx, goestin

-cheers-
 
Old 05-03-2005, 05:50 AM   #2
goestin
Member
 
Registered: Nov 2004
Location: Netherlands (east)
Distribution: debian, suse, novell linux desktop
Posts: 81

Original Poster
Rep: Reputation: 15
ah already got it

----

#!/usr/bin/python2.3
#test.py

import sys # this one does the trick
print sys.argv[1]
----

./test.py 127.0.0.1
-
127.0.0.1




rtfm
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
python problem kenji Linux - Software 1 03-25-2005 12:44 PM
Python problem cdk Linux - General 1 11-06-2004 09:43 PM
Python problem cdk SUSE / openSUSE 1 11-06-2004 08:38 AM
python problem rblau Linux - Software 0 03-03-2004 10:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration