Download MicroMonitor User`s Manual
Transcript
17.22 Some Handy Host-Based Scripts…
The host based tools discussed above allow you to create some handy scripts that automate some of
the interaction that may otherwise be necessary when working with the target. These scripts are part of the
umon source tree and can be found under umon_main/host/src/scripts.
17.22.1 TVI: target vi
This script automates the process of pulling up a file from the target, modifying it, and pushing it back
down to the target. If the environment variable TARGET_IP is set, then it uses that as the IP address of the
target; otherwise the user must specify the IP address of the target as the second argument. One can
immediately see that ‘vi’ can be replaced by any editor (temacs, tnotepad, etc..)…
#!/bin/bash
# tvi: wrap editor (in this case vi) with tftp pull and push so that ASCII
# files on target can be edited on host…
usage()
{
echo "Usage: tvi {filename_on_target} [target ip address]"
echo "(uses \$TARGET_IP if set)"
}
if [ $# = 1 ]
then
if [ "$TARGET_IP" = "" ]
then
usage
exit 1
fi
elif [ $# = 2 ]
then
export TARGET_IP=$2
else
usage
exit 1
fi
tmpfile=`mktemp`
# If mktemp isn’t available just use ‘xxx’.
ttftp $TARGET_IP get '.' $tmpfile
export fullname=`grep ^${1}, $tmpfile`
ttftp $TARGET_IP get $1 $tmpfile
if [ $? != 0 ]
then
exit
fi
vi $tmpfile
ttftp $TARGET_IP put $tmpfile $fullname
rm $tmpfile
17.22.2 TLS: target list
Same idea as “tvi” above, but this simply uses “moncmd” to remotely run “tfs ls *”…
361