Passing awk variable in perl -e call


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing awk variable in perl -e call
# 1  
Old 03-21-2011
Passing awk variable in perl -e call

Hi. I am on a Solaris box and have an awk script which calls perl via the command line:
Code:
timeTester="'"`perl -e 'use Time::Local;my $time = timelocal(10,10,10,10,10,2011
);print $time'`"'"

But I want to pass awk variables into this call. These are the example awk variables:
Code:
secondField = 10
minuteField = 10
hourField = 10
dayField = 10
monthDigit = 03
currentYear = 2011

So I need a call that looks like this:
Code:
timeTester="'"`perl -e 'use Time::Local;my $time = timelocal(secondField,minuteField,hourField,dayField,monthDigit,currentYear
);print $time'`"'"

Does anyone know how to pass the actual awk variable values into this call. There must be some sort of escape character or method. Its driving me mad Smilie

Last edited by Scott; 03-21-2011 at 01:14 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to call a variable in awk again ?

Hi again and thanks to R.Singh. One more question here. The code works in awk. (or GAWK) awk 'BEGIN{print "Enter your Name: ";getline name < "-";print RS "Input entered by user is: "name}' How to display the variable name again ? The awk script is running automaticly to the... (3 Replies)
Discussion started by: Zabo
3 Replies

2. Shell Programming and Scripting

Passing variable from bash to perl script

Hi All, I need to pass a variable from bash script to perl script and in the perl script i am using those variables in the sql query but its giving error : Use of uninitialized value $ENV{"COUNTRYCD"} in concatenation (.) or string at /GIS_ROOT/custom/tables/DBread_vendor.pl line 50. Can ... (6 Replies)
Discussion started by: NileshJ
6 Replies

3. Shell Programming and Scripting

Passing variable into perl system commands

Hi guys, I'm having issues getting the following snippet of my script to work and was hoping for some suggestions. I'm trying to pass a variable in perl system with wget. This is what I need help with: #!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime) ; my... (3 Replies)
Discussion started by: timj123
3 Replies

4. Shell Programming and Scripting

awk programming -Passing variable to awk for loop

Hi All, I am new to AWK programming. I have the following for loop in my awk program. cat printhtml.awk: BEGIN -------- <some code here> END{ ----------<some code here> for(N=0; N<H; N++) { for(M=5; M<D; M++) print "\t" D ""; } ----- } ... (2 Replies)
Discussion started by: ctrld
2 Replies

5. Shell Programming and Scripting

Passing awk variable argument to a script which is being called inside awk

consider the script below sh /opt/hqe/hqapi1-client-5.0.0/bin/hqapi.sh alert list --host=localhost --port=7443 --user=hqadmin --password=hqadmin --secure=true >/tmp/alerts.xml awk -F'' '{for(i=1;i<=NF;i++){ if($i=="Alert id") { if(id!="") if(dt!=""){ cmd="sh someScript.sh... (2 Replies)
Discussion started by: vivek d r
2 Replies

6. Shell Programming and Scripting

Passing perl variable to shell command

Can we pass perl variable to shell commands. If yes, please give some example. (2 Replies)
Discussion started by: Anjan1
2 Replies

7. Shell Programming and Scripting

PERL script -- calling 'sed' by passing 'variable value'.

Hi Friends, I'm calling 'sed' command inside one perl script, which is to list directory names which are having some date value as their names (in the form YYYYMMDD) with in the range (start and end date). #!/usr/bin/perl -w use strict; use warnings; my $DATA = "/export/home/ganapa"; my... (5 Replies)
Discussion started by: ganapati
5 Replies

8. UNIX for Advanced & Expert Users

Passing Hash variable in to sql query in perl

Hi Everyone, Can anyone help me how do i call hash variable in to sql query in perl. Please see the script below i have defined two Hash %lc and %tab as below $lc{'REFF'}='V_RES_CLASS'; $lc{'CALE'}='V_CAP_CLASS'; $lc{'XRPD'}='V_XFMR_CLASS'; $tab{'V_RES_CLASS'}='V_MFR_SERS';... (6 Replies)
Discussion started by: jam_prasanna
6 Replies

9. Shell Programming and Scripting

Passing argument to system call in awk script

So, I have this script. It reads a CSV file that has a mixture of object names with IP addresses (parsing out that part I have working), and object names which have a DNS name. I want to be able to run a "dig +short" based off of the name given to me in the line of the awk script, and then deal... (6 Replies)
Discussion started by: mikesimone
6 Replies

10. Shell Programming and Scripting

Passing variable to perl

I need a non-perl (bash) way to strip the path from a list of "find" results. Below is the perl version which I could use, if I could figure out how to call the script with a variable (like in sh, $1 is the variable passed in ./script variable) $file = "/path/to/file.txt"; # How do I... (2 Replies)
Discussion started by: TheCrunge
2 Replies
Login or Register to Ask a Question