OK
getting an error from my code ./hashtape2 line 11 ctx command not found
any ideas and any suggestions for linux programming book
echo Sanderson Forensics hashtape script
echo
date
echo
echo Creating hash on contents of tape identified as $1
echo command line - hashtape $1 $2
echo
echo rewinding tape
mt -f /dev/nst0 rewind
echo hashing $2 tape files
ctx = 'md5init'
for((i=0;i<$2;i++))
do
ctx='dd if=/dev/nst0 bs=64k | md5update $ctx'
done
echo 'md5final $ctx'
echo
echo complete
date
you can't have spaces between the variable and the equals sign in your line
ctx=`md5init`
Spaces at start of line are ok (for indenting for flow) but not either side of the equals sign.
Also can't tell for sure on web, but those need to be back quotes (not single quotes) so that linux executes the command specified and the output is returned. i.e.
# Single quotes
ctx='echo hi'
echo $ctx
# would produce output echo hi
# Back quotes
ctx=`echo hi`
echo $ctx
# would produce output hi
Pls ignore if this is an egg-sucking lesson ) just mentioning in case.
Phil.
Pls ignore if this is an egg-sucking lesson ) just mentioning in case.
Phil.
No - linux stuff pretty new to me.
OK tried that - no error message but no tape movement either
Tape does not rewind and dd does not happen.
PM sent
Scalability, as I mentioned previously, is the problem with these short bash scripts. Phil's solution is more elegant, no doubt.
On logging the dd output the (non-image) output from dd goes to stderr not stdout, so if you redirect stderr to where you want it, you can capture it.
dd if=/dev/nst0 bs=64k 2> /path/to/log
( ">" redirects stdout, "2>" redirects stderr)
I'm anxious to see what you and Phil work up offline…please post your results.
Barry
( ">" redirects stdout, "2>" redirects stderr)
I should probably mention that if you use "2>" then each iteration will whack the logfile…be sure to use 2>> to append rather than overwrite.
I'm anxious to see what you and Phil work up offline…please post your results.
Phil has been very helpful and has sent some code for me to play with - just having fun trying to get it to compile under redhat (sorry not slackware - but had install probs). Can't seem to sort out the openssl lib and include files - have downloaded the appropriate packages and dependancies - but cant find the include files at the mo.
Also busy on other stuff which means I am at it piecemeal and that doesn't help.
Have dug out an old linux programming book - windoze programming is much easier as you dont need to screw around with makefiles etc. )
OK Phil kindly sent some code over which I have compiled and now run (Barry you will be pleased to know that this is on slackware) on a 30GB tape with 5 tapes files. The hash compares with a hash I took with the windows tools I have written myself - dual verification was the whole point of this exercise. The verification took about 20 minutes.
There are still some issues to address at the moment I have to specify the number of files on the tape before I run the verification (I know this from windows but it is not very elegant). I also need to tidy up the script to create a nice log.
Bascially the code that Phil wrote wraps the three portions of the standard md5 protocol (for want of a better word). So the script calls the md5 init program (rather than routine) then pipes x many tape files from dd into the md5update program, each time passing and capturing the md5 context. Finally it calls the md5final program and prints the hash.
(md5init, md5update and md5final are all functions in the ssl library - that have been wrapped by phil to make them individual porgrams).
Interesting learning curve and a nice practical intro to linux programming for me.