Find the answer to your Linux question:
Results 1 to 6 of 6
I'm currently having issues on saving the following values, printing them in a file and saving them once every 5 mins(using crontab). I need to have the Local timestamp (including ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2013
    Posts
    17

    Smile Having Trouble with displaying the following


    I'm currently having issues on saving the following values, printing them in a file and saving them once every 5 mins(using crontab).

    I need to have the Local timestamp (including the time and date using snmpget), Local ip address (using ifconfig), and the Subnet Mask. And the Remote Timestamp, as well as the Remote ip address and Mask

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    So, what problem do you have? The script, or the configuration of your crontab? In either case, you are not providing enough information, and you aren't showing what you are already trying - try first and then we can better help you...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    May 2013
    Posts
    17
    Quote Originally Posted by Rubberman View Post
    So, what problem do you have? The script, or the configuration of your crontab? In either case, you are not providing enough information, and you aren't showing what you are already trying - try first and then we can better help you...
    Here is the problem that I'm currently having (And this is the work I've done on my Perl Script by far. But i still need to add the Remote Timestamp, Host and the Subnet mask for this one as well).

    #Perl Script: -
    Code:
    #!/usr/bin/perl
    use strict;
    use warnings;
    
    #Declares the Global Variables, and Creates the file as well as appending the values once every 5 minutes.
    my($Test, $File_N, $Lines);
    $File_N = "local";
    open (FILE, ">>$File_N\.log") || die"\n Unable to create the file\.log";
    
    
    
    #Prints out the Values: -
    print FILE "Local Timestamp: ";
    print FILE `date "+%a %b %d %T %Y"`;
    print FILE "$1";
    
    
    print FILE "Local Host: ";
    print FILE `ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $ 1}'`;
    
    print FILE "Local Subnet Mask: ";
    print FILE `ifconfig eth0 | grep 'inet addr:' | cut -d: -f4`;
    
    print FILE "Remote Timestamp: ";
    print FILE `snmpget -c ICT338 -v2c -Oqv tcp:115.146.85.10:1161 iso.3.6.1.4.1.2021.100.4.0\t`;
    
    print FILE "Remote Host: ";
    
    print FILE "Remote Subnet Mask: ";
    
    
    print FILE "$1\n";
    
    #Closes the File 
    close FILE;
    exit
    #Crontab Lines(To add after the script is created): -
    Code:
    #Haven't added the Lines yet.
    #Executes the Perl Script once every 5 Minutes
    #Sends the values stored in the file created by the Perl
    #Script by mailing the file values to the local host using Cron
    #File Created after the Script is Executed(Once every 5 Mins,
    #And Once in a daily biases(At 9:30 AM, the values are sent to the local host mail by using
    #Cron): -
    Code:
    Local Timestamp: "Wed May 15 10:34:18 2013"
    Local Host: 192.168.220.131  Bcast
    Local Subnet Mask: 255.255.255.0
    #Missing Remote Timestamp:
    #Missing Remote Host:
    #Missing Remote Subnet Mask:
    Last edited by Khrz; 05-15-2013 at 04:17 AM.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    I don't see any valid crontab files here... Huh?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    May 2013
    Posts
    17
    Quote Originally Posted by Rubberman View Post
    I don't see any valid crontab files here... Huh?
    That's because I haven't figured out how to get the Remote Host and the Subnet mask as well. But I've managed to get the Remote's Timestamp however. This is why, I don't simply want to activate the crontab lines until I get the values i need.

  6. #6
    Just Joined!
    Join Date
    Nov 2010
    Posts
    3
    Quote Originally Posted by Khrz View Post
    That's because I haven't figured out how to get the Remote Host and the Subnet mask as well. But I've managed to get the Remote's Timestamp however. This is why, I don't simply want to activate the crontab lines until I get the values i need.
    This thread should be: "How can I get remote ip address and remote subnet mask with snmp".

    I donīt know why you say "having trouble with display the following". With this title, we understand you have in your script print $value, but $value is not shown when executing from crontab (very typical problem due to context variables).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •