Hi guys, kind of a newbie question, so I apologize in advance.
First I tried to export an array from one script to it's child, and I
figured it's not supported in bash (would be happy if someone can correct
me). So I pass the array cells one by one. It works for all commands except
for those with redirection signs (| > etc.), see example and error below.
Your help is appreciated!! 

main.sh:
CMDS=("ls -l > /tmp/log")
~/child.sh "${CMDS[0]}"

child.sh:
for i in "$@"
do
        if [ "$i" ]; then
                echo "$i"
                $i
        fi
done

./main.sh
ls -l > /tmp/log
ls: >: No such file or directory
ls: /tmp/log: No such file or directory
-- 
View this message in context: 
http://www.nabble.com/Running-commands-from-array-in-a-child-script-tf4697757.html#a13428706
Sent from the Gnu - Bash mailing list archive at Nabble.com.



Reply via email to