Hi All.
I have the following simple shell program.
It reads a number from the "/user/amit/bldno";
for example: file "bldno" contains value "100"
After execution of the program the content should change to 101.
---------
#!/usr/bin/tcsh
V= `cat /user/amit/bldno`
echo $V
`rm -rf /user/amit/bldno`
NV = expr $V + 1
echo $NV > /user/amit/bldno
---------------------
It is not writing new value to file "/user/amit/bldn
Could pls help.
Thanks
Amit
---------
dmwaff
2
#!/usr/bin/tcsh
V= `cat /user/amit/bldno`
echo $V
`rm -rf /user/amit/bldno`
NV = expr $V + 1
echo $NV > /user/amit/bldno
You have the wrong shell, tcsh, syntax. Your syntax is Bourne (sh) kile, but backward compatible with Korn (ksh) and Bash (bash).
Examples:
#!/usr/bin/tcsh
set V = `cat /user/amit/bldno`
echo $V
rm -f /usr/amit/bldno
set NV = `expr $V + 1`
echo $NV > /user/amit/bldno
#!/sbin/sh
v=`cat /user/amit/bldno`
echo $v
rm -f /usr/amit/bldno
nv=`expr $v + 1`
echo $nv > /user/amit/bldno
#!/usr/bin/ksh
v=$(cat /user/amit/bldno)
echo $v
rm -f /usr/amit/bldno
nv=$((v+1))
echo $nv > /user/amit/bldno