runcommand#
- runcommand(command, printinput=False, printoutput=None, wait=True, **kwargs)[source]#
Make it easier to run shell commands.
Alias to
subprocess.Popen()
. Returns captured output if wait=True, else returns the subprocess.- Parameters:
Examples:
myfiles = sc.runcommand('ls').split('\n') # Get a list of files in the current folder sc.runcommand('sshpass -f %s scp myfile.txt me@myserver:myfile.txt' % 'pa55w0rd', printinput=True, printoutput=True) # Copy a file remotely sc.runcommand('sleep 600; mkdir foo', wait=False) # Waits 10 min, then creates the folder "foo", but the function returns immediately sc.runcommand('find', wait=False) # Equivalent to executing 'find' in a terminal
New in version 3.1.1: print real-time output if
wait=False