LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-22-2006, 09:27 AM   #1
booyaadewd
LQ Newbie
 
Registered: Sep 2006
Posts: 9

Rep: Reputation: 0
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
 
Old 09-22-2006, 11:04 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
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
 
Old 09-22-2006, 11:38 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,988
Blog Entries: 54

Rep: Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743
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

Last edited by unSpawn; 09-22-2006 at 11:57 AM.
 
Old 09-22-2006, 12:47 PM   #4
booyaadewd
LQ Newbie
 
Registered: Sep 2006
Posts: 9

Original Poster
Rep: Reputation: 0
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.
 
Old 09-22-2006, 01:11 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,988
Blog Entries: 54

Rep: Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743
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/
 
Old 09-22-2006, 01:13 PM   #6
booyaadewd
LQ Newbie
 
Registered: Sep 2006
Posts: 9

Original Poster
Rep: Reputation: 0
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

Last edited by booyaadewd; 09-22-2006 at 01:36 PM.
 
Old 09-22-2006, 03:48 PM   #7
booyaadewd
LQ Newbie
 
Registered: Sep 2006
Posts: 9

Original Poster
Rep: Reputation: 0
pretty please could someone make me a wikked script? hehheeheh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[crontab] emailing non-empty results G00fy Programming 5 09-20-2006 01:16 AM
trouble with emailing pictures jabfinger Linux - General 4 09-09-2006 04:01 PM
emailing Four LQ Suggestions & Feedback 3 02-24-2006 09:09 PM
Emailing, easy one this steve007 Linux - Newbie 2 08-01-2005 05:27 AM
emailing on cvs commit allan_y Linux - Software 2 07-02-2004 09:30 AM


All times are GMT -5. The time now is 10:54 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration