Python Forum
execute linux command with arguments - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: execute linux command with arguments (/thread-24352.html)



execute linux command with arguments - sivareddy - Feb-10-2020

import subprocess
myname=raw_input("myname=")
subprocess.call(["pvcreate","/dev/",myname])
Output:
[root@xxx siva]# python test1.py myname=sdc Device /dev/ not found. Device sdc not found.
we are getting this error,but we can created with commands


RE: execute linux command with arguments - Gribouillis - Feb-10-2020

Try '/dev/' + myname. When you write /dev/sdc on the command line, it is a single argument.


RE: execute linux command with arguments - sivareddy - Feb-10-2020

now it's working fine.
Thanks