有兩個問題:如何將此腳本的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