LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help with DD and emailing the results (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-dd-and-emailing-the-results-485987/)

booyaadewd 09-22-2006 09:27 AM

Help with DD and emailing the results
 
Good Morning,

I have a question. I would like to use dd to wipe a drive, i can do this no problem with the command:

dd if=/dev/zero of=/dev/hda bs=1024

what i want to do is actually email a log with the date, time, computer name, and wether the script completed okay to someone.

How could i do this at the command line? Keep in mind i would like to use the a very minimal kernel install to do this. (I think im going to have to add mail to tthe kernel)

thanks
booyaa

marozsas 09-22-2006 11:04 AM

Assuming you already have the machine name and the machine has basic network capabilities and e-mail working, you can do something like this:

Code:


date=$(date)
result="whatever"

mail -s "Put your subject here" booyaadewd@your.isp.com <<EOM
Put the body of message here.
You can use shell variables too.
The current PATH is $PATH.
The date is $date
The script returned the status: $result

end of message.
EOM


unSpawn 09-22-2006 11:38 AM

Asserting similar but w/o the mailx package:
Code:

#!/bin/sh
subj="dd on $(/bin/hostname) on $(/bin/date '+%Y/%m/%d %H:%M:%S') finished with exit code $?"
exec 3<>/dev/tcp/10.0.1.24/25
cat >&3 << endofhere
EHLO localhost
MAIL FROM: booyaa@de.wd
RCPT TO: root@de.wd
DATA
Subject: ${subj}
.
QUIT
endofhere
cat <&3
exit 0

Change 10.0.1.24 to the IP address of the MTA you have access to and the two email addresses, then simply run as "dd if=/dev/zero of=/dev/hda bs=1024; /this/script". Bash conn. method credit: LQ's techguy.


(I think im going to have to add mail to tthe kernel)
If you succeed please post how. I've never seen mail added to the kernel and I wonder if that chimera would be worse than a crossover between say The Fly II (1989) and Lassie (say 2005) ;-p

booyaadewd 09-22-2006 12:47 PM

I think this is going to get better as i go.. i wanted something small (or so i thought) however i think its getting more advanced. Your ideas are great and will be applied... in the end here is what im wanting to do.


find the computer info stored in zisview (zenworks)

cat zisview >> /tmp/zisview.txt

dd if=/dev/zero of=/device

hexdump -C | grep '1' (this makes sure there is nothing but zeros on the drive)

somehow verify that its all 0's

grep /tmp/zisview.txt for the info such as NetBios Name: then whatever the name is, put that into a $machine name variable somewhere, take that and email it to said person@smtpaddress

doesnt sound so simple now that i write it out.. especially when im not a good bash scripter.

unSpawn 09-22-2006 01:11 PM

Well, since you didn't specifically *ask* for a script here's some Bash scripting guides to chew through:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.tldp.org/LDP/abs/html/

booyaadewd 09-22-2006 01:13 PM

okay, ill specifically ask... could someone find the time to write me a script? that would be nice..i would buy them a pizza or something!!!


Heres what i have so far:


#!/bin/bash

DATE=$(date)
RESULT="HD Wipe Complete"
MACHINE="grep -i 'NETBIOS_NAME=' /tmp/machine.name"
NAME="cat /tmp/machine.name"


dcfldd if=/dev/zero of=/dev/sda | dcfldd if=/dev/urandom of=/dev/sda | dcfldd if=/dev/zero of=/dev/sda | dd if=/dev/sda | hexdump -C | grep '1'


mail -s "Hard Drive wiped for $NAME" person@place.com <<EOM
The remote wipe command was issued for $machine & $name.
The script returned the status: $result

end of message.
EOM

booyaa

ps. thanks for the links as well.. ill read them

booyaadewd 09-22-2006 03:48 PM

pretty please could someone make me a wikked script? hehheeheh


All times are GMT -5. The time now is 07:58 AM.