- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: perl localtime help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 01:24 AM
10-02-2006 01:24 AM
perl localtime help
Please advise what I'm doing wrong. Following is my script. I want to stop process if
day = day && start hour = hour && min => start min
The following is not working.
#!/opt/OV/nonOV/perl/a/bin/perl
#
use strict;
my @Array = localtime(time );
my $yy = sprintf("%4.2d", $Array[5] + 1900);
my $dd = sprintf("%2.2d",$Array[3]);
my $mm = sprintf("%2.2d",$Array[4] + 1);
my $hr = sprintf("%2.2d",$Array[2]);
my $mn = sprintf("%2.2d",$Array[1]);
my $sec = sprintf("%2.2d",$Array[0]);
my $wday = (localtime(time))[6];
my $day_of_week = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')[$wday];
my $start_hr = "09";
my $start_min = "30";
if (($wday == 1) && ($hr == $start_hr) && ($mn => $start_min)) {
print "Working.. $start_hr = $hr $mn => $start_min\n";
} else {
print "Not Working..\n";
}
Output:
juniorc->./test_hr_mn.pl
Working.. 09 = 09 23 => 30
Appreciate all help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 01:46 AM
10-02-2006 01:46 AM
Re: perl localtime help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 01:56 AM
10-02-2006 01:56 AM
Re: perl localtime help
What I'm looking for/ want to do is.
if day=day && hr = hr && min = min
system("do something")
else
do nothing
output above
start hr =09 current hr =09
current mn = 23 start min = 30
output: working should only print
if (start hr)09 = 09 && mn =>(start mn)30
23 is not = or > than 30
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 01:57 AM
10-02-2006 01:57 AM
Re: perl localtime help
One more condition:
your perl really is at that path:
#!/opt/OV/nonOV/perl/a/bin/perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 02:11 AM
10-02-2006 02:11 AM
Re: perl localtime help
One little suggestion, that will probably make your program shorter.
I see no reason to use sprintf here-correct me if I'm wrong.
you could take all variables in one line:
my ($sec,$mn,$hr,$dd,$mm,$yy,$wday)=localtime;
correct the month and the year:
$mm+=1;
$yy+=1900;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 02:11 AM
10-02-2006 02:11 AM
Re: perl localtime help
and hr = 09
I want it to do something if day = Mon, Tue etc... and hr =09 and min => 30, 40, etc.
I run the script every 15 min.
Yes perl in #!/opt/OV/nonOV/perl/a/bin/perl
This server have OpenView installed, and that where OpenView install perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 02:16 AM
10-02-2006 02:16 AM
Re: perl localtime help
When it's Monday - it works.
all other days it prints : not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 03:21 AM
10-02-2006 03:21 AM
Re: perl localtime help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2006 05:23 AM
10-02-2006 05:23 AM