Results 1 to 4 of 4
Hi,
I am very new to shell scripting in Linux, i am trying to run the below script but i am getting a syntax error related to 'fi' can anybody ...
- 08-17-2011 #1Just Joined!
- Join Date
- Aug 2011
- Posts
- 2
Shell script giving syntax error
Hi,
I am very new to shell scripting in Linux, i am trying to run the below script but i am getting a syntax error related to 'fi' can anybody help me with the problem. Any help is appreciated, Thanks in advance
:start
clear
echo
echo Deleting Options
echo -------------------------------------
echo
echo '[1] Keep recordings for last 15 days; Delete rest (Today being the First Day)'
echo '[2] Keep recordings for last 30 days; Delete rest (Today being the First Day)'
echo '[3] Keep recordings for last 45 days; Delete rest (Today being the First Day)'
echo '[q] QUIT'
echo
echo
set choice=
set /p choice=ENTER CHOICE COMMAND:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto 15
if '%choice%'=='2' goto 30
if '%choice%'=='3' goto 45
#if '%choice%'=='q' goto quit
echo
goto start
:15
find /archive/*.vox .mtime +15 -exec rm {} \;
#goto start
fi
done
:30
find /archive/*.vox .mtime +30 -exec rm {} \;
#goto start
fi
done
:45
find /archive/*.vox .mtime +45 -exec rm {} \;
#goto start
fi
done
:quit
fi
done
- 08-17-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
err, is this a batch (Windows) script?
- 08-17-2011 #3Just Joined!
- Join Date
- Aug 2011
- Posts
- 2
Yes, I tried to apply the same logic, can u help me with the unix version
- 08-17-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,842
Start here for a good tutorial on using Bash.
In your terminal, do this to see the system documentation for bash:
Use the bash scripts in /etc/init.d/ for examples on code usage.Code:man bash
Basic syntax for a bash script:
Code:func1() { echo Function one } func2(){ echo Function two } read -p "Enter a choice: " choice if [ "$choice" == '1' ]; then func1 elif [ "$choice" == '2' ]; then func2 fi


Reply With Quote