Hi there,
I need some help regarding the execution of shell script from expect as the method I am trying is giving me error. I wrote an shell program which takes two arguments to telnet to a device and saves the output in a file. Following is the script.
#!/usr/bin/bash
# Directory where the log files will be stored
#
DIR=/tmp/Vlan
########################################
if [ ! -e $DIR ]
then
mkdir $DIR
fi
# Collect data from the router
(echo "cic";\
echo "cic123!";\
echo "term len 0";\
echo "show vlan | e VLAN|enet|token|fddi|default|Vlan|vlan|- 0 0 |----|Type";\
echo "q";\
sleep 3)|telnet $1 > $DIR/$1.txt
awk '/active/ {print $1," ",$2}' $DIR/$1.txt > $DIR/$2.txt
=================================================
Now when I try to call it from expect script then the following error occurs. Please guide me how to resolve this issue.
spawn /tmp/infovlan.sh 192.168.111.28 PEAGG
/tmp/infovlan.sh: test: argument expected
If I try to execute it using the below method then the same error is produced.
exec /tmp/infovlan.sh 192.168.111.28 PEAGG
/tmp/infovlan.sh: test: argument expected
however the script runs fine if I run from cli directly.
Regards,