[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Running commands from array in a child script
From: |
bengoavs |
Subject: |
Running commands from array in a child script |
Date: |
Fri, 26 Oct 2007 08:06:28 -0700 (PDT) |
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.
- Running commands from array in a child script,
bengoavs <=