| | |
Unix shell access from Perl script
![]() |
Hello everyone. I am writing a Perl script that will be installed on a Linux host. I need the script to be able to access the current time / date environment variable somtimes. I've looked through a list of the standard CGI variables that can be accessed through $ENV but time / date isn't one of them. Is it possible to pass commands to the host's shell from within a Perl script and have the result piped back into the script? If so I could just pass:
Or maybe there is a simpler way to do this that I'm missing. Any advice would be appriciated.
Steven.
Perl Syntax (Toggle Plain Text)
date
Or maybe there is a simpler way to do this that I'm missing. Any advice would be appriciated.
Steven.
The one question you should not ask when teaching a new language structure is "Do you understand?". Do you understand?
There are a few ways to get the date/time with perl:
http://perldoc.perl.org/functions/gmtime.html
http://perldoc.perl.org/functions/localtime.html
http://perldoc.perl.org/functions/time.html
or you can use backtiks to get the date from the system date function, something like:
http://perldoc.perl.org/functions/gmtime.html
http://perldoc.perl.org/functions/localtime.html
http://perldoc.perl.org/functions/time.html
or you can use backtiks to get the date from the system date function, something like:
my $date = `/bin/date +"%a, %b %d, %Y"`; Last edited by KevinADC; Sep 30th, 2006 at 5:59 pm.
![]() |
Similar Threads
- problem in running perl script (Perl)
- Execute Unix commands from Perl script (Perl)
- A simple perl script (Perl)
- perl script help re: scope/structure for noob (Perl)
- i want help about the Simulate a Linux/UNIX shell, called MASH in the C (C)
- Calculate the amount of time in the linux process using perl script (Perl)
Other Threads in the Perl Forum
- Previous Thread: Simple website hit counter
- Next Thread: ASCII Values for the Keyboard entry
| Thread Tools | Search this Thread |





