- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Calling Perl from Korn 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
тАО12-27-2008 08:58 AM
тАО12-27-2008 08:58 AM
I am new to korn scripting and perl,
My problem is that when i'm calling perl for replacing a number inside a korn script its not working...outside its working.
This is the code :
for subType in `grep ${File_subtype} ${eventFileSpec} | cut -d "," -f18 `
eventDuration=`echo ${subType} | cut -d "," -f18 | cut -d "\"" -f2`
tmp_duration=`expr $eventDuration / $val`
`perl -p -i -e 's/${eventDuration}/${tmp_duration}/' ${eventFileSpec}`
done
Thanks in advance,
Priya
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2008 09:26 AM
тАО12-27-2008 09:26 AM
Re: Calling Perl from Korn Script
The Perl script has no notion of the shell variables as you wrote this:
# perl -p -i -e 's/${eventDuration}/${tmp_duration}/' ${eventFileSpec}
While the shell expands ${eventFileSpec} the single quotes bounding the Perl script prevent the shell from expanding what lies between. Changing the single quotes to double quotes is one way of passing shell variables here:
# perl -p -i -e "s/${eventDuration}/${tmp_duration}/" ${eventFileSpec}
A "better" way is to export the variables into your environment and use the Perl 'ENV' hash :
# export eventDuration=whatever
# export tmp_duration=something
# perl -p -i -e 's/$ENV{eventDuration}/$ENV{tmp_duration}/' ${eventFileSpec}
...notice that we can now return to the use of the (safer) single quotes.
You might have more rapidly discovered the problem here had you added the warning pragma to your Perl script by adding the '-w' flag.
As for the remainder of your Shell code, you need a 'do' as in"
...
for subType in ...
do
...
done
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2008 09:29 AM
тАО12-27-2008 09:29 AM
Re: Calling Perl from Korn Script
After changing to double quotes it worked fine.
Thanks a lot for the help
Priya
:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2008 09:38 AM
тАО12-27-2008 09:38 AM
SolutionWell good, but assigning zero points is hardly correct or a good way to insure future help from folks. Please read:
http://forums11.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2008 09:41 AM
тАО12-27-2008 09:41 AM
Re: Calling Perl from Korn Script
Sorry...I thgt i assigned points...
Priya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-27-2008 09:44 AM
тАО12-27-2008 09:44 AM
Re: Calling Perl from Korn Script
Thanks, and welcome to the HP-UX ITRC Forums!
...JRF...