Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
Created November 2, 2010 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanVaughan/659522 to your computer and use it in GitHub Desktop.
Save IanVaughan/659522 to your computer and use it in GitHub Desktop.
bash shell script that gets the current IP address and xflash version and echos into a file, which is then copied onto a remote host
#!/bin/bash
REMOTE_SERVER=192.168.109.2
#IRV: Cat into same file? What if many try at same time? But would be better cos could tail -f!
#OUTPUT=/path/hosts_${HOSTNAME}.txt #IRV: advantage here is file date/time is updated on target, so dont need to know date here
#OUTPUT=/path/hosts.txt
OUTPUT=hosts.txt
touch $OUTPUT
REMOTE_PATH=/path2
#TIME_STAMP=$(date +%Y%m%d) # doesnt work on blades due to no battery!
echo "----------------------------------------------" >> $OUTPUT
#echo "# This file is auto created via the script /root/current_ips.sh" > $OUTPUT
#echo "# Which is run from /etc/rc.local on each boot of each board" >> $OUTPUT
echo ${HOSTNAME} : ${S2SYSTEM} >> $OUTPUT
ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' >> $OUTPUT
xfflash -i >> $OUTPUT
#scp $OUTPUT $REMOTE_SERVER:$REMOTE_PATH
cat $OUTPUT | ssh $REMOTE_SERVER "cat >> $REMOTE_PATH/$OUTPUT"
rm -f $OUTPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment