-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflashconv.sh
35 lines (27 loc) · 869 Bytes
/
flashconv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/zsh
#flashconv.sh <text.txt> <flashdump.bin>
#xxd didn't work on its own, so this uses a cut piped to xxd... it expects bytes in the text file to be between col 14 and 52
#Quick convert of telnet hex dumps to bin files
INFILE=$1;
OUTNAME=$2
if [ -z "$INFILE" ]; then
echo "flashconv.sh <input-filename.txt> <output-filename.bin>\nERROR: Input filename is missing";
exit;
fi
if [ -z "$OUTNAME" ]; then
echo "flashconv.sh <input-filename.txt> <output-filename.bin>\nERROR: Output filename is missing";
exit;
fi
echo "Selected file: $INFILE";
echo "Output file: $OUTNAME";
if [ ! -f "$INFILE" ]; then
echo "flashconv.sh <input-filename.txt> <output-filename.bin>\nERROR: Input file does not exist.";
exit;
fi
echo "Running..."
$(cut -c14-52 $INFILE | xxd -r -p - $OUTNAME);
if [ $? -eq 0 ]; then
echo "Done!";
else
echo "Failed to convert file.";
fi