Sponsored Content
Top Forums Shell Programming and Scripting Passing variable into perl system commands Post 302962951 by rangarasan on Monday 21st of December 2015 10:57:01 AM
Old 12-21-2015
Quote:
Originally Posted by timj123
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:

Code:
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime) ;

my $TimeStamp=strftime "%Y%m%d",localtime ;
system('wget -q --no-check-certificate -O /tmp/DataFile_$TimeStamp "https://foobar.com/html"') ;

I can't get the $TimeStamp to interpolate into the system command.

Any ideas on solving this?

Thanks in advance.
You need to allow the perl interpreter to interpolate perl variables.

Just try this.!

Code:
system("wget -q --no-check-certificate -O /tmp/DataFile_$TimeStamp 'https://foobar.com/html' ") ;

-Ranga
This User Gave Thanks to rangarasan For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl calling unix system commands

if ( system ("/bin/cat $File1 >> $File2") ) { print("#WARNING RAISED : /bin/cat File1 >> File2 - FAILURE!\n"); } I came across this code, would appreciate if someone can tell me if my understanding is correct? the perl code tell the system to cat file 1 into file 2, if command fails, print... (4 Replies)
Discussion started by: new2ss
4 Replies

2. 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

3. Shell Programming and Scripting

passing variable from bash to perl from bash script

Hi All, I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl FROM_DATE="06/05/2008" TO_DATE="07/05/2008" "perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename" filename has... (10 Replies)
Discussion started by: arsidh
10 Replies

4. Shell Programming and Scripting

Perl System command calls to variable

I am new to scripting in Perl so I have a dumb question. I know I can call system commands using system("date"); But I am not able to: 1. set its output to a variable 2. run in quiet mode(no output to the screen) The examples i have #!/usr/bin/perl print `date +\%y\%m\%d.\%H\%M`;... (5 Replies)
Discussion started by: 4scriptmoni
5 Replies

5. 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

6. Shell Programming and Scripting

Passing variable and wild card character to grep in Perl

HI All, I have a script that needs to find out a list of files in a directory, i pass the search parameter as an argument. opendir ( DIR, $dir ) || die "Error in opening dir $dirname\n"; @filename1 = (grep {/$File_pattern/ } readdir(DIR)); The problem is my file patterns are like... (1 Reply)
Discussion started by: amit1_x
1 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. Shell Programming and Scripting

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: 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: secondField = 10... (0 Replies)
Discussion started by: pedro6994
0 Replies

9. 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

10. 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
DBIx::Class::TimeStamp(3pm)				User Contributed Perl Documentation			       DBIx::Class::TimeStamp(3pm)

NAME
DBIx::Class::TimeStamp - DBIx::Class extension to update and create date and time based fields DESCRIPTION
Works in conjunction with InflateColumn::DateTime to automatically set update and create date and time based fields in a table. SYNOPSIS
package My::Schema; __PACKAGE__->load_components(qw( TimeStamp ... Core )); __PACKAGE__->add_columns( id => { data_type => 'integer' }, t_created => { data_type => 'datetime', set_on_create => 1 }, t_updated => { data_type => 'datetime', set_on_create => 1, set_on_update => 1 }, ); Now, any update or create actions will update the specified columns with the current time, using the DateTime inflator. This is effectively trigger emulation to get consistent behavior across databases that either implement them poorly or not at all. METHODS
get_timestamp Returns a DateTime object pointing to now. Override this method if you have different time accounting functions, or want to do anything special. The date and time objects in the database are expected to be inflated. As such you can be pretty flexible with what you want to return here. AUTHOR
J. Shirley <jshirley@gmail.com> CONTRIBUTORS
Florian Ragwitz (Porting to DBIx::Class::DynamicDefault) LTJake/bricas COPYRIGHT &; LICENSE Copyright 2009 J. Shirley, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2010-09-05 DBIx::Class::TimeStamp(3pm)
All times are GMT -4. The time now is 12:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy