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
Can we pass an array of strings from a Perl Program to a Shell Script? som.nitk Shell Programming and Scripting 0 08-23-2009 02:22 PM
pass variables from one script to another vasuarjula Shell Programming and Scripting 3 12-12-2008 03:09 AM
Need help passing variables in shell script to perl one-liner Xek Shell Programming and Scripting 1 01-15-2008 03:12 PM
How to pass Shell variables to sqlplus use them as parameters Jtrinh Shell Programming and Scripting 1 07-13-2005 04:15 AM
Pass multiple variables to SQL script jagannatha Shell Programming and Scripting 1 10-25-2002 09:45 AM

Reply
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 09-24-2009
xchen89x xchen89x is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 7
pass perl variables to shell script

I have a perl script that opens a text file containing numbers on each line:

for example:

755993
755994
755995
755996
755997
755998

The perl script takes these numbers and store them as an array @raw_data, where I can access individual numbers by using $raw_data[0] for the value 755993.

What I want is to pass the variable $raw_data[0] and the following numbers ($raw_data[1] ... $raw_data[77]) one by one into a shell script (bash) where I can store them as the variable ID_NUMBER (for example) and be able to use the value in my shell script. In case, I wasn't clear, I want to pass $raw_data[0] into my shell script, save it as the variable ID_NUMBER, run the rest of the shell script, then pass $raw_data[1] into the script and do the same thing as before.

I'm hoping someone can provide a solution to this problem. I've tried using the system() command in perl and possibly I'm doing it wrong, but it hasn't worked out for me.

Thanks in advance!
  #2 (permalink)  
Old 09-24-2009
varontron varontron is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 110
Thumbs up

you could execute your perl script from a shell script to capture the perl script output like this:

Code:
#!/bin/sh
for each in list
do
  ID_NUMBER=`perl myscript.pl`
  # do more stuff
done
or you can do this from within perl:
Code:
#!/bin/perl

for ... {
  ...
  $ENV{ID_NUMBER}=$myval;
  system("do_something_with_ID_NUMBER.sh");
}
  #3 (permalink)  
Old 09-24-2009
xchen89x xchen89x is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 7
Thank you! I'll give that a shot.
Sponsored Links
Reply

Bookmarks

Tags
bash, perl, shell, variable

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 05:14 AM.


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