How to run shell commands from python.
eg. How to use 'echo $a' commands? where a is any variable.
sasdap
0
Newbie Poster
Recommended Answers
Jump to PostTry this:
import os a = 'hello' cmd_string = "echo $%s" % a os.system(cmd_string)
Jump to Posthi,
It was returning the return code(0). How to get the output as 'hello'?
The return value is 0 because the command you gave, actually executed successfully.
os.sytem("echo hello"); os.system("ren file-old file-new")
If you want to print something on the screen, there is already…
All 5 Replies
ZZucker
342
Practically a Master Poster
sasdap
0
Newbie Poster
sneekula
969
Nearly a Posting Maven
katharnakh
7
Posting Whiz in Training
Jimleeeel
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.