I don't know whether it is possible that I ask for help concerning a shel sscript that i wrote and which is not working.
So here is my shell script:
#! /bin/bash
if($#argv != 1) then
echo "hoge"
exit
endif
set tgtdir = ../../result
set target = ${tgtdir}/s${argv[1]}/1
set datafile = "agent.csv track.csv knock.csv check.csv"
set paramfile = "agentdata.csv statemap.csv"
echo "experiment 1 start..."
./main 1
echo move to ${target}
if(!(-d ${target})) then
mkdir -p ${target}
endif
mv ${datafile} ${target}
cp ${paramfile} ${target}
So i attribute the rights for the execution using the chmod +x and then i execute while i m in the directory where the script sheel is located:
./exp.sh 14 but still no directory is created in the directory result and also i got the error argv:command not found ! I cannot find the reason . it might be so clear but i m mind blinded ! Please help me and thanks for your assistance.
How did you use csh instead of bash ? Did you change the shebang? Show us what you did. I noticed that you changed endif to fi twice, but that is the wrong syntax in csh. If you want to rewrite the script to bash you need to make more changes...
... more changes as Scrutinizer said:
use if [ ... ]
argv does not exist in bash: use $# and/or $1 .... $n
set has a different function, use tgtdir="../../result" (NO spaces around "="!)
Why do you run ./main ? If that's the name of your script, that'san infinite recursion that will blast your system resources...