Questions tagged [os.system]

os.system is a python standard library function. It executes the given string argument as a command in a subshell.

638 questions
-1
votes
1 answer

pass integer variable and string in os.system in python

I am getting SyntaxError: invalid syntax or TypeError: unsupported operand type(s) for +: 'int' and 'str' . Here portnum is integer and the rest are string or #!/usr/bin/python import getpass import sys import MySQLdb import os …
mysqlrockstar
  • 2,536
  • 1
  • 19
  • 36
-1
votes
2 answers

Python os.startfile Can't Find The FIle

I'm having a problem with Python programming. In my program I use a os.startfile() to start a program but it won't let me. When my program is executing the command to start the file I get the following error in the Windows Script Host: Script: …
CoolJWB
  • 69
  • 1
  • 2
  • 10
-1
votes
1 answer

os.system not writing in terminal

i have a simple test file i created in order to use vmd (a program for my job) This test file is as simple as : import os os.system("vmd -eofexit < VMD_script.tcl -args 3spi_cholesterol") Basically, im using os.system to launch a program name vmd…
Tanjay
  • 11
  • 2
-1
votes
1 answer

EOL while scanning string literal / on a try os.sys() cmd

I saw already many question on that topic but I cannot get any solution to my code. I believe that the problems comes from the space that I try to put between two arguments or from the sed command. Please I need some help. Thanks a lot…
-1
votes
1 answer

Subproces.call executing c++ script fails

In order to execute a c++ script I made, I am using: subprocess.call(args, shell=True) Whenever I execute this script via console, it prints 2 strings (one at the beginning and another at the end) and creates a file (output.txt) My problem is that…
-1
votes
1 answer

Difference between os.system("cmd") and commands.getoutput("cmd") ...?

I'm trying to print today's date using os.sytem and commands.getoutput using python. My code is : import os, commands print os.system("date +%Y%m%d%T") print commands.getoutput("date +%Y%m%d%T") =========Ouput :-============= Case 1:…
Naive
  • 492
  • 3
  • 8
  • 20
-1
votes
1 answer

How to detect what output is and do if statement from it?

Basically I am writing a script in Python that will check for me the status of my servers. I need it to ping five different IPs and then detect what the output is. I will then need an if statement for example: import.os Server1 = os.system('ping…
oreid
  • 1,336
  • 2
  • 13
  • 25
-1
votes
2 answers

Python, trying to run a program from the command prompt

I am trying to run a program from the command prompt in windows. I am having some issues. The code is below: commandString = "'C:\Program Files\WebShot\webshotcmd.exe' //url '" + columns[3] + "' //out…
Parris
  • 17,833
  • 17
  • 90
  • 133
-1
votes
1 answer

Call a python function using os.system

I am calling a function, func_1.py, from my main one (func.py) using import os cmd = 'python func_1.py [x y t]' os.system(cmd) x, y and t are defined before in func.py. func_1.py starts with def the_reader(index, x, y, peak_number):. When I run…
albus_c
  • 6,292
  • 14
  • 36
  • 77
-1
votes
1 answer

How do we check whether a os.system() function has executed properly if not then print "os.system could not work"

How do we check whether an os.system() function has executed properly, and if it didn't then print os.system could not work? For example: import os os.system('ping 192.168.1.1') How do we know the cmd command was executed, and how can we get its…
-1
votes
2 answers

Detecting shell error in python when using os.sytem()?

I am calling this perl script from http://www.linguistics.ruhr-uni-bochum.de/~dipper/software/tokenize.perl where given an input file, it gives outputs a file in another format. But when the perl script gives a shell error through python's…
alvas
  • 115,346
  • 109
  • 446
  • 738
-1
votes
1 answer

Using sed in a Jython script to replace a whole line with a variable in a text file

In a Jython script I am trying to replace an entire line of a text file (the 2nd line in this case) with a directory address that contains a variable (VAR). obsids=str(obsids[i]) print type(obsids) os.system('sed -i "2 s:.*:/usr/data/$obsids/:"…
-2
votes
1 answer

Escape quote in python os.system("command")

I want to run the following command via os.system(command) echo '@include("acf/rows.php")' >> ../functions.php I can't seem to get the escaping of quotes right. How do I do this?
-2
votes
1 answer

Cannot create correct path to use it with os.system

I know similar questions are apearing all the time, but I have read all I can find. Solutions there helped me a bit, but I still cannot build correct full path that contains whitespaces. After research I found solution adding \ and take everyting in…
klakson
  • 3
  • 3
-2
votes
1 answer

Python3 How should I execute this complex shell command

I would like to execute this shell command through python, I tried to use shell="ls *R1.fastq.gz|while read a; do b=${a%R1.fastq.gz}R2.fastq.gz; c=${a%R1.fastq.gz}R1.out.fq; d=${a%R1.fastq.gz}R2.out.fq; e=${a%R1.fastq.gz}.s.fq; echo "sickle pe -t…
ThiBei
  • 3
  • 2
1 2 3
42
43