Sunday, December 13, 2009

[Sed] Delete one or more lines from a file - The solution

[Sed] Delete one or more lines from a file - The solution: "Remove the 3rd line:

sed '3d' fileName.txt



Removal of the line containing the string 'awk':

sed '/awk/d' filename.txt



Remove the last line:

sed '$d' filename.txt




Remove all empty lines:

sed '/^$/d' filename.txt
sed '/./!d' filename.txt"

expect in bash script ? - Dev Archives

expect in bash script ? - Dev Archives: "#!/bin/bash

RESULT=`echo 'set timeout -1
spawn ssh someaddress
expect {
Password: {send -- \'mypass\r\'; exp_continue}
user@ {send -- \'dosomething\r\'; exp_continue}
user@ {send -- \'exit\r\'}
} eof | expect -f -`

echo $RESULT
}"

Saturday, December 5, 2009

Absoblogginlutely! » Dell Open Manage Server Administrator (OMSA) alert setup – updated

Absoblogginlutely! » Dell Open Manage Server Administrator (OMSA) alert setup – updated: "Dellalert.bat should now contain the following lines.

@echo off
::Dell alert program
::v1.21
::Set variables below as appropriate
::needs blat downloaded (http://tinyurl.com/2qdxea) Put blat.exe in the system path
::No longer needs blat installed as configuration is set in the environment variables.

@echo on
setlocal
set log=c:\jobs\dell.txt
set pager=destinationpageraddress@company.com
set mail=destinationemailaddress@company.com
set company=Companyname
set server=%computername%
set mailserver=mailservername
set alertfrom=fromemailaddress@company.com

date /t >%log%
time /t >>%log%
echo %* >>%log%
if {%1}=={p} blat %log% -to %pager% -server %mailserver% -f %alertfrom% -subject “%company% %server% alert – %*”
if not {%1}=={} blat %log% -to %mail% -server %mailserver% -f %alertfrom% -subject “%company% %server% alert – %*”
endlocal

The commands to specify the call to dellalert.bat are below. Note that you need to specify cmd.exe and then the batch file. As the batch file has parameters with quotes, the quotes need to escaped with backslashes (as per the information below). I highly recommend you save these commands to a batch file called conf.bat and then run the batch file – a lot easier to manage, recall and implement on multiple servers. Each line starts with omconfig – you will probably find your web browser has wrapped the lines, but if you copy/paste the content into notepad your lines should be correct.

omconfig system alertaction event=batterywarn execappath=”cmd /c \”c:\jobs\dellalert p battery probe warning\”'
omconfig system alertaction event=batteryfail execappath=”cmd /c \”c:\jobs\dellalert p battery probe failure\”'
omconfig system alertaction event=fanwarn execappath=”cmd /c \”c:\jobs\dellalert fan probe warning\”'
omconfig system alertaction event=fanfail execappath=”cmd /c \”c:\jobs\dellalert p fan probe failure\”'
omconfig system alertaction event=hardwarelogwarn execappath=”cmd /c \”c:\jobs\dellalert hardware log warning\”'
omconfig system alertaction event=hardwarelogfull execappath=”cmd /c \”c:\jobs\dellalert p hardware log failure\”'
omconfig system alertaction event=intrusion execappath=”cmd /c \”c:\jobs\dellalert chassis intrusion detected\”'
omconfig system alertaction event=memprefail execappath=”cmd /c \”c:\jobs\dellalert p memory prefailure\”'"