Reputation: 2804
I want to execute the following command:
ssconvert /data/sam.xls,/data/test.csv
I have tried:
p = subprocess.Popen(["ssconvert", '/data/sam.xls','/data/test.csv'], stdout=subprocess.PIPE,shell=True)
out = p.communicate()
print"output", out
but it's not working.
How can I solve this issue?
Upvotes: 0
Views: 984
Reputation: 414795
The correct command is not ssconvert /data/sam.xls,/data/test.csv
. It should be: ssconvert /data/sam.xls /data/test.csv
instead (note: the space, not comma between the input and output filenames).
If you use shell=True
then you should pass the command as a string. There is no need to use shell=True
in this case. If shell=False
(default) then each command-line argument should be passed as a single list item:
#!/usr/bin/env python
import subprocess
subprocess.check_call(['ssconvert', '/data/sam.xls', '/data/test.csv'])
See Why subprocess.Popen doesn't work when args is sequence?
Upvotes: 0
Reputation: 2804
This is worked
import subprocess
subprocess.call(["ssconvert","sample.xlsx","sample.csv"],cwd="pathtoyourfile") # pathtoyourfile must contain the xlsx and csv files
Upvotes: 1