There are two problems:
- Your shell syntax is simply not valid, you are missing key semicolons or newlines.
- You can't pass in a complete shell script as separate arguments.
The correct syntax is:
for c in $(seq 1 10); do echo $c; done
Note the ; after the for ... in ... part before do, and another one after each command inside the do ... done block. You could also use newlines:
for c in $(seq 1 10)
do
echo $c
done
Put your whole shell script in one argument; the argument is passed to sh -c ... and the -c switch expects the whole script in a single argument value:
shell_command = 'for c in $(seq 1 10); do echo $c; done'
call(shell_command, shell=True)
or, alternatively, using newlines:
shell_command = 'for c in $(seq 1 10)\ndo\n echo $c\ndone'
call(shell_command, shell=True)
or
shell_command = '''
for c in $(seq 1 10)
do
echo $c
done
'''
call(shell_command, shell=True)
shell_command = 'for c in $(seq 1 10); do echo $c; done', thencall(shell_command, shell=True)`. Note the semicolons I added.