有两个问题:如何将此脚本的shell变量写入其子脚本?编写shell脚本的shell脚本
有没有更简单的方法来做到这一点?
如果你不能按照我在做什么,我:
1)开始,他们的名字将被存储为$我
2所值的目录列表)CD “荷兰国际集团为$我每天值,并通过使用echo猫
4)和猫用目录的名称ls'ing其内容
3)呼应其内容到一个新的脚本编写一个新的脚本包含$ i的ls'd值并将它们全部发送到博客电子邮件地址叫做$ [email protected]
#/bin/sh
read -d '' commands <<EOF
#list of directories goes here
dir1
dir2
dir3
etc...
EOF
for i in $commands
do
cd $SPECIALPATH/$i
echo ("#/bin/sh \n read -d '' directives <<EOF \n") | cat >> $i.sh
ls | cat >> $i.sh
echo ("EOF \n for q in $directives \n do \n uuencode $q $q | sendmail $i \n done \n") | cat >> $i.sh
# NB -- I am asking the script to write the shell variable $i into the new
# script, called $i.sh, as the email address specified, in the middle of an
# echo statement... I am well aware that it doesn't work as is
chmod +x $i.sh
./$i.sh
done
为什么你必须写脚本呢?你不能执行代码吗? – alternative 2010-09-05 12:37:53