Python Forum
execute linux command with arguments
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
execute linux command with arguments
#1
import subprocess
myname=raw_input("myname=")
subprocess.call(["pvcreate","/dev/",myname])
Output:
[[email protected] 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
Reply
#2
Try '/dev/' + myname. When you write /dev/sdc on the command line, it is a single argument.
Reply
#3
now it's working fine.
Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to run linux command with multi pipes by python !! evilcode1 2 467 Jan-25-2021, 11:19 AM
Last Post: DeaD_EyE
  Running linux command line apps... dbrdh 0 667 Jan-30-2020, 01:14 PM
Last Post: dbrdh
  changing the process command line arguments in python Skaperen 3 1,224 Aug-19-2019, 02:40 PM
Last Post: wavic
  Long command with characters not working in Python on Oracle Linux 7 iaas_infra 10 2,547 Jul-19-2019, 04:53 PM
Last Post: ichabod801
  Linux command output not working adam2020 2 1,247 Mar-23-2019, 01:20 PM
Last Post: adam2020
  Issue with command line arguments artblinked 2 1,320 Feb-22-2019, 03:04 PM
Last Post: artblinked
  How to iterate over command line arguments? zBernie 5 7,056 Nov-23-2018, 04:34 PM
Last Post: wavic
  Pyinstaller to execute a script in command prompt Ciroxxx 0 1,209 Sep-18-2018, 10:17 AM
Last Post: Ciroxxx
  search and store a value from linux command output in to variable python prazy29 1 1,701 Apr-06-2018, 01:56 PM
Last Post: wavic
  Functions (Arguments Passing,Changing a mutable ,Assignment to Arguments Names) Adelton 2 2,257 Mar-02-2017, 10:23 PM
Last Post: zivoni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020