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:
[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
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 pass a mongdb command to a module and execute it. cspower 0 275 Feb-03-2024, 09:54 PM
Last Post: cspower
  Is possible to run the python command to call python script on linux? cuten222 6 629 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  Using subprocess to execute complex command with many arguments medatib531 5 1,716 Apr-27-2023, 02:23 PM
Last Post: medatib531
  How to use a variable in linux command in python code? ilknurg 2 1,547 Mar-14-2022, 07:21 AM
Last Post: ndc85430
  use subprocess on linux\pi wwith a "grep " command korenron 2 7,901 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  how to run linux command with multi pipes by python !! evilcode1 2 6,216 Jan-25-2021, 11:19 AM
Last Post: DeaD_EyE
  Running linux command line apps... dbrdh 0 1,619 Jan-30-2020, 01:14 PM
Last Post: dbrdh
  changing the process command line arguments in python Skaperen 3 2,942 Aug-19-2019, 02:40 PM
Last Post: wavic
  Long command with characters not working in Python on Oracle Linux 7 iaas_infra 10 6,127 Jul-19-2019, 04:53 PM
Last Post: ichabod801
  Linux command output not working adam2020 2 2,654 Mar-23-2019, 01:20 PM
Last Post: adam2020

Forum Jump:

User Panel Messages

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