I have a situation where, I need to call a bash script inside a python script which is in turn called inside another python script.
download-output-files.py:
#!/usr/bin/env python
import os
import sys
for i in node_path:
cmd="python watcher.py "+i
os.system(cmd) ##calling another python script
watcher.py:
#!/usr/bin/env python
import os
import time
if 'finish' in child:
print "finish found"
cmd="./copy_output_file.sh "+node
os.system(cmd) ##Calling shell script here
copy_output_file.sh:
#!/bin/bash
filepath=$1
cp ff /home/likewise-open/TALENTICA-ALL/mayankp/kazoo/$filepath
When I run download-output-files.py , it calls watcher.py , which in turn calls copy_output_file.sh and below is the error I face:
mayankp@mayankp:~/kazoo$ python download-output-files.py
finish found
sh: 1: Syntax error: Unterminated quoted string
When I run the same commands in Python shell, it runs bash script successfully. What am I missing?
filepath=$1should befilepath="$1", etc. shellcheck.net is a great tool for checking such things.