Python Forum
<SOLVED>os.system needs a string in quotes
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
<SOLVED>os.system needs a string in quotes
#11
(Oct-06-2016, 03:10 AM)snippsat Wrote: You shall call it without [] when argument are in a list.
 
subprocess.call(cmd)

sorry about not checking that he was making a list in the call.  my habit is to make lists and do as you say and not have [] in the call.  i ended up jumping to conclude that he did,  my bad.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#12
This works perfectly!
cmd = [ "srm", "-rv", path ]
subprocess.call(cmd)
I can even delete folders and files with really weird names like
Quote:/home/fred/Git/this "is" a test of (srm)
or
Quote:/home/fred/Git/who (am) "I" 'going' to be?



Yahoo!
Thanks guys! :dance:
OS: Arch
Editor: Atom with Material Syntax UI and the Termination terminal plugin

Micah 6:8
Reply
#13
(Oct-06-2016, 05:03 PM)Fred Barclay Wrote: I can even delete folders and files with really weird names
Expected since they are passed directly to the command without being tinkered with by a shell.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] Sub string not found in string ? jehoshua 4 1,355 Dec-03-2024, 09:17 PM
Last Post: jehoshua
Question [SOLVED] How to replace characters in a string? Winfried 2 967 Sep-04-2024, 01:41 PM
Last Post: Winfried
  Need help on how to include single quotes on data of variable string hani_hms 5 6,952 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  [SOLVED] [BeautifulSoup] Why does it turn inserted string's brackets into &lt;/&gt;? Winfried 0 2,663 Sep-03-2022, 11:21 PM
Last Post: Winfried
  [SOLVED] [BeautifulSoup] Turn select() into comma-separated string? Winfried 0 1,892 Aug-19-2022, 08:07 PM
Last Post: Winfried
  Adding string after every 3rd charater [SOLVED] AlphaInc 2 2,027 Jul-11-2022, 09:22 AM
Last Post: ibreeden
Question [SOLVED] Delete specific characters from string lines EnfantNicolas 4 3,196 Oct-21-2021, 11:28 AM
Last Post: EnfantNicolas
  Replace String in multiple text-files [SOLVED] AlphaInc 5 11,036 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
  Replace String with increasing numer [SOLVED] AlphaInc 13 8,053 Aug-07-2021, 08:16 AM
Last Post: perfringo
Thumbs Up Parsing a YAML file without changing the string content..?, Flask - solved. SpongeB0B 2 3,052 Aug-05-2021, 08:02 AM
Last Post: SpongeB0B

Forum Jump:

User Panel Messages

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