Store output from os.system in a variable

Store output from os.system in a variable

Postby risingh » Wed Nov 19, 2014 12:10 pm

I do a lookup on internet using CURL. I automated this using a python script to take an IP as an argument and further run CURL using that.

I tried the following: maxm = os.system('curl -u "Username : Password " %s' %url) But still the output gets displayed on terminal and not as value for variable "maxm".

I even tried subprocess.popen. But that dint work though.

Seeking help to resolve this.

Regards
Richa
Last edited by stranac on Wed Nov 19, 2014 1:18 pm, edited 1 time in total.
Reason: First post lock.
risingh
 
Posts: 1
Joined: Wed Nov 19, 2014 12:04 pm

Re: Store output from os.system in a variable

Postby stranac » Wed Nov 19, 2014 1:24 pm

Why do you want to call curl from your python code?
Python has libraries that can do this in a much simpler way than calling an external process.
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1790
Joined: Thu Feb 07, 2013 3:42 pm


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 3 guests