Linux tips and tricks for all users.

Voyager probe leaving us and thoughts on the end of the world and Perl.

The Voyager probe is finally approaching the edge of the heliosphere; the massive sphere that encloses the entire solar system; very soon the lonely probe will finally be entering deep space and it will be truly alone. This probe is travelling at just about 38,000 miles per hour and it is destined to encounter another star system in the year 299,000. But sadly the nuclear power source will be dead long before then. If only we had the webway; the system of travel around the Universe in the Warhammer 40,000 Universe. Then you could walk from Earth to Alpha Centauri and back through the webway. Assuming that the planet Earth had an opening into the webway to begin with. But if it did then you could walk anywhere in the galaxy in a conceivable time frame. But realistically; we are constrained by the speed of light and we do not have any known shortcuts through the galaxy as of yet that we could exploit. The nearest star to us is 4 and a half light-years away from us; but that is a very long period of time to travel; the Voyager probe would take 77,500 years to reach the star if it had been sent there. That is a fact that we have to deal with. Travelling to the moon or to Mars would be a more realistic option in the long run.

But we could get to Mars; the only problem is the amount of radiation that the astronauts would be exposed to during the journey. If you wish to simulate space travel on your computer; the Celestia application is perfect. This is a 3D application that simulates all of the known objects in the space around us. You can fly from Earth to Jupiter at a certain speed and it will take a realistic amount of time to get there. For example, if you fly from Earth to Alpha Centauri; it would take 4 and a half years to get there. This is an amazing application for learning about the Universe and visiting some far away objects without the Klingons and Borg messing up your trip. Stellarium is another awesome application for learning the night sky; this application involves viewing the simulated night sky from the surface of Earth and clicking on an object to get information about it. A good application to have with you when you are outside to learn what the points of light are in the sky. Kstars is yet another incredible application for learning about the night sky; this application lets you view the sky as seen from the ground and you can highlight a celestial object to learn what it is.

There is even the ancient Xephem program; this is an ancient UNIX application and although it does not seem to be available for installation on my Linux Mint 12 Debian Edition distribution; the source code is still available and you could build from that. This program has many cool features; you can view the solar system at any point in time; and no there is no planetary alignment in December 21 2012. The whole Mayan prophecy thing is blown out of all proportion; the world is not going to end anytime soon; the UNIX epoch will still continue and there is not going to be an alien invasion or anything out of the ordinary. But there are bound to be some doomsday cults who believe the most retarded things about the end of the world and end of the Mayan calendar. If the world was going to end in 2012; why would the UNIX cal command have a 2013 calendar. I have heard that the world will end in the the year 5000; but I doubt it. There could be an earthquake that triggers the Yellowstone super volcano and that could cause some damage; but nothing that could kill everyone on the planet. People should just enjoy the ending of this year and a new start in 2013; the world will still be here.

                            2013
      January               February               March          
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
       1  2  3  4  5                  1  2                  1  2  
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   3  4  5  6  7  8  9  
13 14 15 16 17 18 19  10 11 12 13 14 15 16  10 11 12 13 14 15 16  
20 21 22 23 24 25 26  17 18 19 20 21 22 23  17 18 19 20 21 22 23  
27 28 29 30 31        24 25 26 27 28        24 25 26 27 28 29 30  
                                            31                    

       April                  May                   June          
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6            1  2  3  4                     1  
 7  8  9 10 11 12 13   5  6  7  8  9 10 11   2  3  4  5  6  7  8  
14 15 16 17 18 19 20  12 13 14 15 16 17 18   9 10 11 12 13 14 15  
21 22 23 24 25 26 27  19 20 21 22 23 24 25  16 17 18 19 20 21 22  
28 29 30              26 27 28 29 30 31     23 24 25 26 27 28 29  
                                            30                    

        July                 August              September        
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6               1  2  3   1  2  3  4  5  6  7  
 7  8  9 10 11 12 13   4  5  6  7  8  9 10   8  9 10 11 12 13 14  
14 15 16 17 18 19 20  11 12 13 14 15 16 17  15 16 17 18 19 20 21  
21 22 23 24 25 26 27  18 19 20 21 22 23 24  22 23 24 25 26 27 28  
28 29 30 31           25 26 27 28 29 30 31  29 30                 

      October               November              December        
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
       1  2  3  4  5                  1  2   1  2  3  4  5  6  7  
 6  7  8  9 10 11 12   3  4  5  6  7  8  9   8  9 10 11 12 13 14  
13 14 15 16 17 18 19  10 11 12 13 14 15 16  15 16 17 18 19 20 21  
20 21 22 23 24 25 26  17 18 19 20 21 22 23  22 23 24 25 26 27 28  
27 28 29 30 31        24 25 26 27 28 29 30  29 30 31

Here are some more Linux commands for you to try out over the holidays. This one will print information about the terminal you are using.

john@debian-mint ~$ stty
speed 38400 baud; line = 0;
eol = M-^?; eol2 = M-^?; swtch = M-^?;
ixany iutf8

And this command will display information about a particular file.

john@debian-mint ~$ stat kfreebsd-9.0-1-486.gz 
  File: `kfreebsd-9.0-1-486.gz'
  Size: 5123572   	Blocks: 10008      IO Block: 4096   regular file
Device: 801h/2049d	Inode: 135578722   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-10-18 10:02:38.000000000 +1100
Modify: 2012-06-16 05:24:36.000000000 +1000
Change: 2012-10-18 10:14:39.767949929 +1100
 Birth: -

The Perl programming language has an implementation of stat(3). That allows a script to display information about a file by calling the stat function on the file. This can be useful sometimes. Linux has many useful scripting languages that can make your life easier. This code snippet below will print out the size of a file in kilobytes.

#!/usr/bin/perl

use File::stat qw(:FIELDS);

my $file = "hello.jpg";

stat($file) or die "No $file: $!";

my $filesize = stat("$file")->size;

printf("Size: %s\n\n", $filesize / 1024);

And this is an example from an old Perl CGI script I coded a long time ago.

unless ( $html_page eq "") {
	print "Current Selected Page:  $server\/$html_page Statistics.\n";

	$mode = (stat($html_page))[7];	 # The Filesize in Bytes.
	$modeverbose = sprintf("%f", $mode); # Perl 5.6+ !
	$modehex = sprintf("%X", $mode); # Perl 5.6+ !
	$modebin = sprintf("%b", $mode); # Perl 5.6+ !
	$access2= (stat($html_page))[11];	 # The Filesystem block size for filesystem I/O.
	$access3= (stat($html_page))[9];	 # Last modification time in seconds since Epoch.

	print "This script ©  2004 John Cartwright.\n";
	print "File Size: $modeverbose Bytes. $modehex Bytes, ('Hexadecimal'). $modebin Bytes, ('Binary').\n";
	print "File Block Size for File System I/O: $access2.\n";
	print "File Last Modified: $access3. Seconds since 0:00 January 1, 1970 GMT.\n";
}

Post a Comment

Your email is kept private. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current day month ye@r *