Last active
January 4, 2017 10:07
-
-
Save sagi-z/e8a549d759a7bc5f26019d5f1eacca2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" = "-h" ]; then | |
echo "Usage: $0 [filename]" | |
exit | |
fi | |
# Get the IP automatically - this will prompt for a password because of sudo usage | |
ip=`sudo arp-scan -localnet | perl -ne 'print $1 if /(\S+).*Rigol/i'` | |
if [ "$ip" = "" ]; then | |
echo "Could not detect a Rigol device connected to the LAN. Aborting!" | |
exit | |
else | |
echo "Found a Rigol at $ip" | |
fi | |
# The user can optionally supply a name for the capture | |
filename="$1" | |
if [ "$filename" = "" ]; then | |
# Generate a capture name if not supplied | |
now=`date +%d%m%Y_%X` | |
filename="capture_${now}" | |
else | |
# Otherwise just make sure no path/suffix is given | |
filename=`basename $filename` | |
filename=`echo $filename | sed -e 's/\..*//'` | |
fi | |
filename="${filename}.bmp" | |
# All the captures will go into this directory | |
# which is created if it doesn't exist | |
output_dir="${HOME}/Pictures/RIGOL" | |
mkdir -p $output_dir | |
# Capture | |
output="${output_dir}/$filename" | |
if [ -e $output ]; then | |
echo "File $output already exists. Delete or move it first. Aborting!" | |
exit | |
fi | |
echo -n "Capturing..." | |
echo ':display:data?' | netcat -w 20 $ip 5555 | tail -c +12 > $output | |
echo "done" | |
# Let the user know where the output is | |
echo "capture saved at '${output}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment