Hi
i am running the below script in vio server,
i changed to aix mode..then
#./script1
</code>
##Set today Date as file name.
vardate= date +"%m%d%y%H%M%S"
varhost= hostname
filename= "$varhost_$vardate"
echo $filename
</code>
the output is .......
</code>
# ./mount_test
110408141603
tstvio1
./mount_test[4]: : 0403-006 Execute permission denied.
</code>
can anyone explain why i am getting the error on line4 of the script.
thanks
The values are not assigned properly to the variables. Replace these lines:
vardate= date +"%m%d%y%H%M%S"
varhost= hostname
filename= "$varhost_$vardate"
with:
vardate=$(date +"%m%d%y%H%M%S")
varhost=$(hostname)
filename="$varhost_$vardate"
You can also use backticks to assign the output of a command to a variable:
vardate=`date +"%m%d%y%H%M%S"`
varhost=`hostname`
Regards
thanks franklin,
i used backticks, but not worked. see below..
script:
#print "$filename"
vardate= `date +"%m%d%y%H%M%S"`
varhost= `hostname`
filename="$varhost_$vardate"
print $filename
output:
root@web1:> ./test
./test[6]: 110408144257: not found
./test[7]: tstweb1: not found
thanks
Don't ever use "test" as name for a Unix script. It is a command that evaluates conditional expressions.
PS And try this:
filename=$varhost"_"$vardate
thnak you shock neck
here is the output,
root@tstweb1:/home/mmuppane> ./test1
./test1[6]: 110408151456: not found
./test1[7]: tstweb1: not found
_
not worked,...
thanks
Huh?
##Set today Date as file name.
vardate=$(date +"%m%d%y%H%M%S")
varhost=`hostname`
filename=$varhost"_"$vardate
print $filename
(0)aserver:/home/shockneck > ksh -x t.sh
+ :
+ + date +%m%d%y%H%M%S
vardate=110408212104
+ + hostname
varhost=aserver
+ filename=aserver_110408212104
+ print aserver_110408212104
aserver_110408212104
(0)aserver:/home/shockneck >
thanks shockneck,,
the main problem is ,,
i gave a single spaces between varxxx and date/host.
that was wired me from morning.
thanks a lot.