- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Using a perl command within a sh script
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
Discussions
Discussions
Forums
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
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
тАО11-12-2004 02:26 AM
тАО11-12-2004 02:26 AM
$process_date = $date->prev;
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 02:29 AM
тАО11-12-2004 02:29 AM
Re: Using a perl command within a sh script
will run the commands give from then command line or from within a shell script.
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 02:38 AM
тАО11-12-2004 02:38 AM
Re: Using a perl command within a sh script
PROCESS_DATE=$(perl -e 'print scalar localtime(time() - 86400)')
echo "Process Date = ${PROCESS_DATE)"
Plan B.
PROCESS_DATE=$(caljd.sh $(caljd.sh -p 1))
echo "Process Date = ${PROCESS_DATE)"
Search Forums for caljd.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 02:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 03:01 AM
тАО11-12-2004 03:01 AM
Re: Using a perl command within a sh script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 03:05 AM
тАО11-12-2004 03:05 AM
Re: Using a perl command within a sh script
Then you have to stick with common date format (same as date prints).
Otherwise you need to do (very little) postprocessing of the list localtime() returns in list context
(see "perldoc -f localtime")
However, your intended Perl command looks to me as if you were using some Date manipulation module (like Date::Manip or Date::Calc, or whatever) because you seem to invoke a method call on an object reference.
For this OO style to work you would need to load the module (if it's not core Perl, what I doubt), and get an object reference first.
Since I don't know what module you are using I'd use this hypothetical module Date::Magic
e.g.
PROCESS_DATE=$(perl -MDate::Magic -e 'print Date::Magic->new('now')->prev')
Of course you have to check what module you were using in your script, what the name of the constructor is, and what parameters it takes for object initialization.
grep your script for lines that have
lines with 'use' or 'require'.
So I'd think you better stick with localtime()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 03:23 AM
тАО11-12-2004 03:23 AM
Re: Using a perl command within a sh script
lt09:/home/merijn 105 > perl -MDate::Manip -le'print ParseDate("yesterday")'
2004111117:21:05
lt09:/home/merijn 106 > perl -MDate::Manip -le'print ParseDate("now")'
2004111217:21:19
lt09:/home/merijn 107 >
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2004 03:49 AM
тАО11-12-2004 03:49 AM
Re: Using a perl command within a sh script
#!/usr/bin/sh
PROCESS_DATE=$(perl -e '($mday,$mon,$year) = (localtime(time() - 86400)) [3,4,5]; printf("%04d%02d%02d",$year + 1900,$mon + 1,$mday)')
echo "Process date = ${PROCESS_DATE}"
If I got all that typed in correctly; it should work. Note that you must add 1900 to the year and 1 to the months as localtime() returns months in the range 0-11 (as does its C counterpart); simularly years are years since 1900 CE.
Plan B:
#!/usr/bin/sh
PROCESS_DATE=$(caljd.sh -y -s $(caljd.sh -p 1))
echo "Process date = ${PROCESS_DATE}"
Invoke as caljd.sh -u for full usage and examples.