Thursday, May 10, 2007

while loop with ssh issue

somehow while loop with ssh only read the first line from the input file & exit without reading the next lines.
eg:
$ cat server.txt
server1
server2
server3
$ while read server
> do
> echo $server
> ssh $server uptime
> done < server.txt
server1
13:15:08 up 49 days, 1:07, 5 users, load average: 0.00, 0.00, 0.00
the uptime command will only be run on the server1 but not on the server2 or server3. to resolve this, use the -n option with ssh, which prevents ssh from reading from standard input:
> ssh -n $server uptime

alternatively, you can use for loop. should be no issue ;)
$ for server in `cat server.txt`
> do
> echo $server
> ssh $server uptime
> done
for more info - http://sial.org/howto/shell/while-ssh/

Monday, May 07, 2007

How to be a Great Dad - 12 Awesome Tips

i found this article on how to be a great dad here at http://zenhabits.net/2007/05/how-to-be-a-great-dad-12-awesome-tips/

the 1st tip is:
  1. Put their interests first, always. Do you enjoy drinking or smoking? Guess what — it’s not good for them, and you’re setting an example with everything you do. I quit smoking about 18 months ago not for my sake, but for my kids. Now, it is still important to take care of yourself (otherwise you can’t take care of them), but you should still have them in mind.
and this remind me to the conversation with my son a few weeks ago...
- while i was driving back home from fetching abang from his school, abang & adik was arguing about using the word "aku". actually adik was using "aku" & abang told adik not to use that word & told her sister that she can only use the word when she grown up. the conversation went like this:

adik: aku bla bla bla (i can't remember what was the sentence)
abang: daddy, adik cakap aku daddy. (abang reported to me)
me: adik, not good la cakap aku.
abang: aah, dah besar cam daddy jer nanti boleh cakap aku.

and then out of nowhere abang asked me:
abang: daddy, abang besar nanti boleh hisap rokok cam daddy?
dang!!! check mate aku!
me: !!?? (terkedu sekejap before i said no cannot, not good)

well i guess it's time for me quit smoking... nahhh not now :P may be later...

anyway, go read the article above. good one!

Thursday, May 03, 2007

chage: can't lock shadow password file

i got this error "chage: can't lock shadow password file" when executing below command:
# chage -E 2008-04-28 username
google said that this error because of these 2 files exist /etc/passwd.lock or /etc/shadow.lock. they are created when a user is made with useradd command. they contain the PID of the command creating them (useradd). once the PID is gone (useradd exits) the locks no longer apply and should probably have been removed by the process that created them.

in the other word, if you remove these files, you should be able to use back the chage command above. but in my case it's still failed!

turn out that the server just rebooted & one of the start up script is hanging. the script is to start an application & need to su to one user & turn out that the user's password has expired! (got this when try to su to the user - "You are required to change your password immediately (password aged)" & hang there!)

the hanging script!
root 31001 31000 0 May02 ? 00:00:00 /bin/sh /etc/rc3.d/S99apps start
root 31002 31001 0 May02 ? 00:00:00 su - user -c /apps/startapps
killed those processes & settled! :)

p/s: changing a users passwd or locking/unlocking an account does not change, create, or remove these files.

Sunday, April 08, 2007

f1

FORMULA 1, PETRONAS MALAYSIAN GRAND PRIX 2007
6 - 8 APRIL 2007

the ticket

the sticker

the place

the merchandise

the fan

the girl

the rules

the entrance

the race

the car

the lap

the pitstop

the crowd
the hill

the spectator

the flag

the earplug

the vvip

the celebrity

the winner

the driver

the end

- see u next year! thanks to my lovely wife for the tickets.

Friday, April 06, 2007

sent file as an attachment from unix

for my reference & knowledge sharing on how to sent text file as an attachment from unix.
most of the ways i found on net, they suggest to do like this:
$ uuencode filename.txt attachment_name.txt | mailx -s "file attach" user@domain.com
it works fine but you'll not get the same format as your original file. in other word the text file format totally screw up!

so you should using this instead:
$ unix2dos -437 filename.txt | uuencode attachment_name.txt | mailx -s "file attach" user@domain.com
go figure out yourself what -437 is for :P