LinuxQuestions.org
Help answer threads with 0 replies.
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 10-28-2010, 11:55 AM   #1
investmentbnker75
Member
 
Registered: Oct 2007
Location: Eastern Seaboard
Distribution: CentOS
Posts: 162

Rep: Reputation: 15
python help


All,

I have a script that i want to add some functionality to, but im new to python. Right now it runs command line as ./script https://server user passwd verbose , which returns alot of informtion. I would like it to be able to only return information for a particular function when a flag is passed.

exp: ./script https://server user passwd verbose -m (for memory only)

Under the ClassesToCheck section are the different things that can be retrieved. I would like that when you run the script as ./script https://server user passwd verbose -m, it returns only the 'Memory' info. -c would be for 'CPU', etc...

Also, i would like the OK at the end of the script to be the first line that is return in the output instead of the last.

Thanks for any help!

Last edited by investmentbnker75; 11-02-2010 at 09:00 AM. Reason: wrong info
 
Old 10-28-2010, 12:36 PM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,240

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
This is the part of the standard library that you use to handle command-line arguments:

http://docs.python.org/library/argparse.html

The documentation is written so that you can pick it up even if you're new to Python. If you're too new to understand the documentation for that module, then spend an couple of hours going through the Python.org tutorial first, and then go back and read it again. Then you'll be ready to add the flags.

I assume you are, as you say, asking for help (read: where to get information on how to do it yourself) and not for work to be done for you.

Quote:
Also, i would like the OK at the end of the script to be the first line that is return in the output instead of the last.
That's easy. Move it up in the script. Cut it out and paste it wherever you want it.

BTW, removing the indentation from Python code changes its meaning. This, as well as the use of [CODE] tags to preserve the indentation, has been pointed out to you before. You were also handed a link to an excellent Python resource in that thread.

EDIT: Okay, which moron rated this unhelpful?

Last edited by dugan; 04-27-2011 at 09:02 AM.
 
0 members found this post helpful.
Old 10-28-2010, 02:08 PM   #3
investmentbnker75
Member
 
Registered: Oct 2007
Location: Eastern Seaboard
Distribution: CentOS
Posts: 162

Original Poster
Rep: Reputation: 15
Im actually looking for someone who can provide me with the code, i seem to be having a hard time understanding python. But thanks for your link anyway.
 
  


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
How can I uninstall a python package installed with python setup.py install? milomak Linux - Software 1 11-16-2009 09:22 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
LXer: Review: Programming in Python 3: A Complete Introduction to the Python Language LXer Syndicated Linux News 0 01-26-2009 04:50 AM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 03:44 AM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 07:54 PM

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

All times are GMT -5. The time now is 07:48 PM.

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