![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replace aword in a.The replaced word should not be overwitten in perl(details inside) | madhul2002 | Shell Programming and Scripting | 7 | 02-21-2009 08:10 PM |
| doing grep inside perl file | bp_vardhaman | Shell Programming and Scripting | 5 | 09-08-2008 06:43 AM |
| Run the command inside perl script | vinay123 | Shell Programming and Scripting | 1 | 06-13-2008 11:01 AM |
| calling a C executable from inside a Perl script | mark_nsx | Shell Programming and Scripting | 3 | 10-07-2005 06:49 AM |
| Perl log parcer. (for custom logs details inside) | Optimus_P | Shell Programming and Scripting | 1 | 08-30-2002 06:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Using Perl Inside KSH
Hi there, I am new to Perl and KSH. The system I am using picks up the KSH scripts and uses them in a batch job control system. I am trying to set a variable from a perl command Code:
#!/bin/ksh -eaxp #******************************************************************************* # Testing Program #******************************************************************************* #+ #job "TEST":U* #- $time='perl -e 'print localtime();'' I cannot figure out how to make KSH capture the output of Perl scripts. Anyone have any insight on this? Thank you in advance, I know how annoying these questions can be. |
|
||||
|
you need to use backticks (i.e. ` ,on the tilde key, most likely) around your perl command, not single quotes, and remove the $ when you set the var, like so: Code:
time=`perl -e 'print localtime();'` then you can ref the var with $ like in 'echo $time' |
|
||||
|
My problem now is pass variables this way. Code:
typeset -Z4 Var Var=1234 rm -rf myfile perl -e -'open (POSTSET, ">myfile"); print POSTSET $Var; close (POSTSET);' Perl never gets that variable $Var. How do I pass Perl the variable from KSH? Thanks. Last edited by Franklin52; 10-02-2009 at 04:36 AM.. Reason: Please use code tags! |
|
||||
|
all shell variables are stored in the $ENV hash built in to perl. to access: Code:
perl -e -'open (POSTSET, ">myfile");
print POSTSET "$ENV{Var}"
close (POSTSET);'
That being said, unless this is just sample code, as Jim pointed out, perl does seem like overkill here. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|