The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
perl -write values in a file to @array in perl meghana Shell Programming and Scripting 27 06-07-2009 05:05 PM
ksh construct ajcannon Shell Programming and Scripting 2 09-27-2007 09:08 AM
Embedding xnest in C code lesnaubr High Level Programming 4 08-13-2007 02:27 PM
Problem with looping construct mikie Shell Programming and Scripting 6 09-07-2006 08:48 AM
extracting info from Unix database to construct a visual diagram fusion99 UNIX for Advanced & Expert Users 0 11-30-2004 01:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-07-2007
svetlur svetlur is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 1
Embedding Perl construct in ksh...

Hi,

I have an embedded Perl construct in a korn script. However, I cannot seem to access the shell variables that were declared outside this Perl section.

This is how my script is written....I have also tried back-ticks where I assign the shell variable to my local perl variable, still doesn't work.

#!/usr/ksh
shell_var1
shell_var2
..
some ksh code..
..
# perl section below...
perl <<-'EOF'
local $perl_variable1=${shell_var1}
..
some code
..
EOF
..
..

Please help. Thanks in advance!

Cheers,
Vit
  #2 (permalink)  
Old 06-07-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Use the %ENV hash to access environment variables. Environment variables will not normally become Perl variables (unless you write some code to do so) magically. But note that, because perl is executed as a process, you cannot change the corresponding environment variable in the shell from Perl, because what you will get from Perl is just a copy:

Code:
$ ( export TEST="me"; perl -e 'print $ENV{"TEST"}, "\n"'; )
me
$ echo $0
ksh
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0