Sponsored Content
Full Discussion: PERL help needed
Top Forums Shell Programming and Scripting PERL help needed Post 302828377 by itkamaraj on Tuesday 2nd of July 2013 10:16:55 AM
Old 07-02-2013
use sprintf
Code:
#!/usr/bin/perl
open LOGFILE,">logfile.txt";
($day, $month, $year) = (localtime)[3,4,5];
printf LOGFILE ("The current date is %04d.%02d.%02d\n", $year+1900, $month+1, $day);
$path = "/app/syslog/logs/" . sprintf("%04d.%02d.%02d",$year+1900, $month+1, $day) . "/[SERVERNAME]/messages";
print $path;
close (LOGFILE);

$ perl date.pl 
/app/syslog/logs/2013.07.02/[SERVERNAME]/messages

This User Gave Thanks to itkamaraj For This Post:
 

10 More Discussions You Might Find Interesting

1. AIX

Perl.rte needed..

Hello I was installing ssh in Aix 4.3 but found that "perl.rte and rpm.rte" was not installed. but to my bad luck i was not able to find these packages for Aix 4.3. Ibm site just has these packages only for 5L. Can anyone help me in finding these packages. Bala (1 Reply)
Discussion started by: balaji_prk
1 Replies

2. Shell Programming and Scripting

different result on shell and on perl HELP NEEDED

hi i am using this command which would return to be the filename ls -l $dir1 | awk '{print $9}' however on perl when i use: `ls -l $dir1 | awk '{print \$9}' > tmp` it gives me a different result. Everything is the same however a directory does not contain the the forward slash so i... (2 Replies)
Discussion started by: nookie
2 Replies

3. Shell Programming and Scripting

Perl - help needed

Hi all, I'm a rookie in Perl scripting, and I have a task to do. Generally it's something like that: I have a reference file consisting of a number and name, tab-separated. One entry in one line, about 99 lines in file. The other file is an XML log file, where in one specific branch, eg.... (8 Replies)
Discussion started by: tklich
8 Replies

4. Shell Programming and Scripting

Help Needed Perl

Hi, I need your help on this script wherein I am matching up the input phone numbers for a partical pattern (xxx-xxxx). However in this I want to have null output where first value of input is null. ( For Example: $record = " ,111-5555") . Ideally I would expect to recieve input in this format... (6 Replies)
Discussion started by: john_prince
6 Replies

5. Shell Programming and Scripting

Perl Script Help Needed

I need this script to be able to check both IPs that are given to it and exit with an OK... if one of those expected IPs is returned. The script is run like this: /bin/dns_checker.pl -s 69.34.55.66 -q htt.jababa.com -e 69.44.56.33,45.47.43.55 Right now, the script is failing, but when I... (4 Replies)
Discussion started by: SkySmart
4 Replies

6. Shell Programming and Scripting

Perl script help needed..

Hi, I am new to perl scripting. Can anybody help me in solving the below problem. I have file, which is called map_file. According to map_file's last column data, i need a output file, which has repeats as like the map_file's last column name. Thank you in advance Vasanth (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

7. Shell Programming and Scripting

Perl command help needed

#!/bin/bash perl -nle' /(?:date|time|ref)/ and print join " ", /(?:date|time|ref)+/g or print ' inputfile Problem I have is that I want to delete words that are on the line of the 3 words above (date, time, and reference). However, I do not want to delete the words... (9 Replies)
Discussion started by: linuxkid
9 Replies

8. Shell Programming and Scripting

Perl script needed

For the following command I need a perl script equivalent with a couple of more things - cat /tmp/mail |grep Appname > /tmp/mail1;cat /tmp/mail >> /tmp/mail1; mail -s "mail subject here" allan@mail.com < /tmp/mail1; >/tmp/mail ; >/tmp/mail1 ================== cat /tmp/mail ***** Alert *****... (4 Replies)
Discussion started by: jacki
4 Replies

9. Shell Programming and Scripting

Help needed with Perl Script

i have the following script: #!/usr/local/bin/perl use STUN::Client; use Data::Dumper; use strict; my $stun_client = STUN::Client->new; $stun_client->stun_server('10.59.29.14'); my $r = $stun_client->get; my $ip = $r->{ma_address}; print "IP: $ip\n\nResult (hash):... (5 Replies)
Discussion started by: SkySmart
5 Replies

10. Shell Programming and Scripting

perl regex help needed

Hi, I want to validate strings in perl, the string may contains characters from a-zA-Z0-9 and symbols +-_.:/\ To validate such a string I computed a regex if ($string =~ m/^/) { print "valid"; } else { print "invalid"; } but this regex also validates strings that contain... (8 Replies)
Discussion started by: zing_foru
8 Replies
rotatelogs(8)						      System Manager's Manual						     rotatelogs(8)

NAME
rotatelogs - rotate Apache logs without having to kill the server SYNOPSIS
rotatelogs logfile rotationtime [offset] DESCRIPTION
rotatelogs is a simple program for use in conjunction with Apache's piped logfile feature, which can be used like this: CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common This creates the files /var/logs/logfile.nnnn where nnnn is the system time at which the log nominally starts (this time will always be a multiple of the rotation time, so you can synchronize cron scripts with it). At the end of each rotation time (here after 24 hours) a new log is started. OPTIONS
logfile The path plus basename of the logfile. If logfile includes any Otherwise, the suffix .nnnnnnnnnn is automatically added and is the time in seconds. Both formats compute the start time from the beginning of the current period. rotationtime The rotation time in seconds. offset The number of minutes offset from UTC. If omitted, zero is assumed and UTC is used. For example, to use local time in the zone UTC -5 hours, specify a value of -300 for this argument. PORTABILITY
The following logfile format string substitutions should be supported by all strftime(3) implementations, see the strftime(3) man page for library-specific extensions. %A full weekday name (localized) %a 3-character weekday name (localized) %B full month name (localized) %b 3-character month name (localized) %c date and time (localized) %d 2-digit day of month %H 2-digit hour (24 hour clock) %I 2-digit hour (12 hour clock) %j 3-digit day of year %M 2-digit minute %m 2-digit month %p am/pm of 12 hour clock (localized) %S 2-digit second %U 2-digit week of year (Sunday first day of week) %W 2-digit week of year (Monday first day of week) %w 1-digit weekday (Sunday first day of week) %X time (localized) %x date (localized) %Y 4-digit year %y 2-digit year %Z time zone name %% literal `%' SEE ALSO
httpd(8) March 2001 rotatelogs(8)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy