I am trying to execute a script ksh that reads a file and execute other script to access the MySQL database. But the second script doesn't return any result. Does anyone know why? please.
#!/bin/ksh
vet=($(cat lasts_tasks.txt))
echo ${vet[@]}
for workunit in ${vet[@]};
do
echo "workunit:$workunit"
exe="/var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult $workunit;"
echo ""$exe
result=`$exe`
echo $result
done
The results are:
# ./lerArquivo.sh
m52cc_job_5 m52cc_job_6 m52cc_job_7
workunit:m52cc_job_5
/var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult m52cc_job_5;
workunit:m52cc_job_6
/var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult m52cc_job_6;
workunit:m52cc_job_7
/var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult m52cc_job_7;
But when I execute the lines alone, I have the right result:
# /var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult m52cc_job_7;
105
The ;
in your command is interpretted as a literal semicolon, so you're basically running
/var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult m52cc_job_6\; ;
Just remove the semicolon from your exe
variable:
#!/bin/ksh
vet=($(cat lasts_tasks.txt))
echo ${vet[@]}
for workunit in ${vet[@]};
do
echo "workunit:$workunit"
exe="/var/www/boinc/m52cc/query_tasks.sh m52cc -workunitResult $workunit"
echo ""$exe
result=`$exe`
echo $result
done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.