Thursday, December 17, 2009

How to mount a CD ROM in Solaris

Determine the name of the device by entering the following command:

   ls -al /dev/sr* |awk '{print "/" $11}'

This command returns the name of the CD-ROM device. In this example, the command returns the string /dev/dsk/c0t6d0s2.

Enter the following commands to mount the CD-ROM:

   mkdir -p /cdrom/unnamed_cdrom
   mount -F hsfs -o ro /dev/dsk/c0t6d0s2 /cdrom/unnamed_cdrom

where /dev/dsk/c0t6d0s2 represents the name of the device that was returned in the preceding step and /cdrom/unnamed_cdrom represents the CD-ROM 3 mount directory.

Monday, October 12, 2009

Funny Linux

% cat "food in cans"
cat: can't open food in cans

% nice man woman
No manual entry for woman.

% "How would you rate Quayle's incompetence?
Unmatched ".

% Unmatched ".
Unmatched ".

% [Where is Jimmy Hoffa?
Missing ].

% ^How did the sex change operation go?^
Modifier failed.

% If I had a ( for every $ the Congress spent, what would I have?
Too many ('s.

% make love
Make: Don't know how to make love. Stop.

% sleep with me
bad character

% got a light?
No match.

% man: why did you get a divorce?
man:: Too many arguments.

% !:say, what is saccharine?
Bad substitute.

% %blow
%blow: No such job.

% \(-
(-: Command not found.

$ PATH=pretending! /usr/ucb/which sense
no sense in pretending!

$ drink matter
matter: cannot create


Source: Gizmodo


Friday, September 25, 2009

How to open port 80/http and 443/https on Fedora Core 10

Login as root


# vi /etc/sysconfig/iptables

Add these lines

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Restart iptables


# /etc/init.d/iptables restart


Wednesday, August 12, 2009

Ignore Ctrl-C in perl and shell scripts

Perl

Add to code :
$SIG{'INT'} = 'IGNORE';


Shell scripts

Add to code :
trap "" 1 2 3 15

Simple Logging in Perl

Set a Logging Variable

my $logging=1

Conditionally Open and Close the Logfile

At the earliest reasonable time, open the logfile in append mode:
if($logging){open FILE , ">>./my.log";}
At the latest possible time, close the logfile
if($logging){close FILE};
Don't
forget to close the logfile as part of your error handling routines as
well. Perl cleans things up nicely for you, but there are always
exceptions to those kinds of rules.

Logging Subroutine

A simple subroutine to enable logging as follows:
sub logit{
if ($logging){
print FILE "$_[0]\n";
}
}
It
prints whatever it receives in the first parameter to the log file. If
you need to print something simple, just call "logit('text to log');"
and your log entry will be created.

Source : http://www.stevekallestad.com/blog/simple_logging_in_perl.html