Simple thing but avoids our repetative daily work.
To set alias name for your frequently used machine.
#Go to /etc/hosts
vi /etc/hosts
#Make an entry for your machine
#IPAddress Hostname Alias
127.0.0.1 connectmachine.com connect
#Restart your network
/etc/rc.d/init.d/network restart
Once it's done. do a ping to check it up
ping connect
About Me
Thursday, 5 February 2009
Wednesday, 26 November 2008
How to Change the Timezone in Linux
Changing Timezone in linux.
1) Change to the directory /usr/share/zoneinfo, where you can find list of timezone regions
2) Move your existing time zone
mv /etc/localtime /etc/localtime-old
3) Link the timezone u needed to localtime
ln -sf /usr/share/zoneinfo/America/Pacific /etc/localtime
4) Update the system time by
/usr/bin/rdate -s time-a.nist.gov
5) Set the ZONE entry in the file /etc/sysconfig/clock file (e.g. "America/Los_Angeles")
6) /sbin/hwclock --systohc
1) Change to the directory /usr/share/zoneinfo, where you can find list of timezone regions
2) Move your existing time zone
mv /etc/localtime /etc/localtime-old
3) Link the timezone u needed to localtime
ln -sf /usr/share/zoneinfo/America/Pacific /etc/localtime
4) Update the system time by
/usr/bin/rdate -s time-a.nist.gov
5) Set the ZONE entry in the file /etc/sysconfig/clock file (e.g. "America/Los_Angeles")
6) /sbin/hwclock --systohc
Wednesday, 8 October 2008
Visual block in VI
Do you need to perform multiple line edits at a single stretch.
I came across VISUAL BLOCK in vi editor.
CTRL + v makes you to enter the visual mode for your file.
select multiple lines
SHIFT + i gives you the insert mode
Enter the text at beginning of the block
Press ESC twice to apply changes to all lines.
I came across VISUAL BLOCK in vi editor.
CTRL + v makes you to enter the visual mode for your file.
select multiple lines
SHIFT + i gives you the insert mode
Enter the text at beginning of the block
Press ESC twice to apply changes to all lines.
Blogged with the Flock Browser
Thursday, 25 September 2008
PERL script for extracting log file based on time
Below code extracts the huge log file based on time frame passed.
#!/usr/bin/perl
use strict;
my $file;
my $times = 0;
my $needed_response_time = 0;
my $start;
my $end;
sub Usage
{
my ($msg) = $_[0];
if ($msg)
{
print STDERR "$msg \n";
}
print STDERR << "EOHELP"
Usage: split_access_log_by_time
options:
-t- :: time interval for which the log is needed
-g
#!/usr/bin/perl
use strict;
my $file;
my $times = 0;
my $needed_response_time = 0;
my $start;
my $end;
sub Usage
{
my ($msg) = $_[0];
if ($msg)
{
print STDERR "$msg \n";
}
print STDERR << "EOHELP"
Usage: split_access_log_by_time
options:
-t
-g
PERL script to combine two csv files
Below script is used to combine two csv files based on the first column. For example, it is assumed both the file has first column related to project names.
#!/usr/bin/perl -w
$FILE1 = $ARGV[0];
$FILE2 = $ARGV[1];
$PROJECTFILE = $ARGV[2];
my %File1Map = ();
my %File2Map = ();
open(FILE1) or die("Could not open $FILE1 file.");
foreach $line () {
# ($Project,$Attachments,$Announcements,$Documents,$Discussions,$Users,$ArtifactTypeCount,$Alm) = split(',',$line);
($Project,$values) = split(',',$line,2);
# my $tempval="$Attachments,$Announcements,$Documents,$Discussions,$Users,$ArtifactTypeCount,$Alm";
my $tempval = $values;
# print "$Project,$values";
$tempval =~ s/\r|\n//g;
$File1Map{"$Project"} = "$tempval";
}
close(FILE1);
open(FILE2) or die("Could not open $FILE2 file.");
foreach $subline() {
($proj,$izcount) = split(',',$subline);
$File2Map{"$proj"}="$izcount";
}
close(FILE2);
open(PROJECTFILE) or die("Could not open $PROJECTFILE file.");
foreach $projname() {
($name,$dummy)=split('\n',$projname);
my $existingValue=$File1Map{"$name"};
my $newValue=$File2Map{"$name"};
if (! defined $existingValue)
{
$existingValue = ",,,,,,,,";
}
if (! defined $newValue)
{
$newValue = "\n";
}
print "" . $name . "," . $existingValue . "," . $newValue;
}
#!/usr/bin/perl -w
$FILE1 = $ARGV[0];
$FILE2 = $ARGV[1];
$PROJECTFILE = $ARGV[2];
my %File1Map = ();
my %File2Map = ();
open(FILE1) or die("Could not open $FILE1 file.");
foreach $line (
# ($Project,$Attachments,$Announcements,$Documents,$Discussions,$Users,$ArtifactTypeCount,$Alm) = split(',',$line);
($Project,$values) = split(',',$line,2);
# my $tempval="$Attachments,$Announcements,$Documents,$Discussions,$Users,$ArtifactTypeCount,$Alm";
my $tempval = $values;
# print "$Project,$values";
$tempval =~ s/\r|\n//g;
$File1Map{"$Project"} = "$tempval";
}
close(FILE1);
open(FILE2) or die("Could not open $FILE2 file.");
foreach $subline(
($proj,$izcount) = split(',',$subline);
$File2Map{"$proj"}="$izcount";
}
close(FILE2);
open(PROJECTFILE) or die("Could not open $PROJECTFILE file.");
foreach $projname(
($name,$dummy)=split('\n',$projname);
my $existingValue=$File1Map{"$name"};
my $newValue=$File2Map{"$name"};
if (! defined $existingValue)
{
$existingValue = ",,,,,,,,";
}
if (! defined $newValue)
{
$newValue = "\n";
}
print "" . $name . "," . $existingValue . "," . $newValue;
}
Subscribe to:
Posts (Atom)
