msgbartop
Tips and Tricks site for advanced HP-UX Engineers
msgbarbottom

10 Nov 19 How to be a yes man

Learning something new is great. Joe Geiger taught me something cool that I should have learned years ago.

Serviceguard users ever wanted to script a cluster change such as a node add.

cmapplyconf -v -P <package file>

Ends with a y/n prompt do you want to apply? Normally that requires input. Not with the yes command:

cmcheckconf -v -P <package file>

rc=$?

# Check return code if not zero stop

if [ ${rc} -ne 0 ]

then

echo “Checkconf error ${rc}”

exit ${rc}

fi

yes | cmapplyconf -v -P <package file>

# Check return code here as well

Tags: , , , ,

30 Nov 10 awk trick of the day. Parsing comma delimited input to a sequential file

Lets say I have a list of servers a mile long to visit.  Got a help desk request with the servers listed separated by commas.

server1,server2,server3

Lets say It is actually about 30 or 40 servers and I’m too lazy to edit the list

echo “server1,server2,server3” > olist

awk -F, -v nr=1 ‘{ for (x=nr; x<=NF; x++) {printf $x ” \n”; }; print ” ” }’ olist

Output:

server1

server2

server3

Plug and play time here, you can take care of any delimited format like this.

Spaces input by wordpress (thanks)

Tags: , ,

sidebarbottom
sidebartop
sidebarbottom
WhatsApp chat