Sponsored Content
Top Forums Shell Programming and Scripting passing variable from bash to perl from bash script Post 302198206 by arsidh on Thursday 22nd of May 2008 10:27:22 AM
Old 05-22-2008
Error 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
Code:
FROM_DATE="06/05/2008"
TO_DATE="07/05/2008"

"perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename"

filename has following data :-
Code:
06/05/2008-07:59
06/05/2008-07:59
06/05/2008-07:59
06/05/2008-07:59
06/05/2008-07:59
07/05/2008-07:59
07/05/2008-07:59
07/05/2008-07:59
07/05/2008-07:59
07/05/2008-07:59:server5:DISK
08/05/2008-07:59:server1:DISK
08/05/2008-07:59:server2:DISK
08/05/2008-07:59:server3:DISK
08/05/2008-07:59:server4:DISK
08/05/2008-07:59:server5:DISK

if we hard code the values of FROM_DATE and TO_DATE it is working.I feel what to know why it is not working When i passing it as variable.
it will be great if some one telle me How to pass the variable to perl properly. Smilie
i am new to perl world.
Thanks
Arsidh

Last edited by Yogesh Sawant; 05-22-2008 at 12:57 PM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing options to a bash script

I'm just not sure where to start looking into this. I want to be able to create switches for my script. Back in the day I'd make my scripts interactive...you know: echo "what report do you want" echo "A)boxes with errors" echo "B)boxes with more than 5 errors" echo "C)Service groups that have... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

2. Shell Programming and Scripting

Passing a MySql password from bash script

Hi all, I am running this script on Mandrakelinux release 10.1, 2.6.8.1-12mdksmp #1 SMP I have also installed 'expect' separately. I have created an Rsync script, but before any Rsync command does run, a MySql dump must be done first, and I am battling a bit to pass the MySql password from... (2 Replies)
Discussion started by: codenjanod
2 Replies

3. Shell Programming and Scripting

Passing Bash variable to javascript

How do I pass a bash variable to a javascript? I've tried #!/bin/bash echo "Content-type: text/html" echo "" echo "<html>" echo "<head>" counter=0 echo '<script> window.parent.document.forms.counter.value = "$counter"; </script>' I have an iframe script which I am trying to pass a... (3 Replies)
Discussion started by: numele
3 Replies

4. Shell Programming and Scripting

Trouble with passing Variable from bash to awk gsub command

Would really appreciate it if someone could point out my mistake in this line of code, i've been staring blankly at it trying everything i can think of some time now and coming up with nothing. #!/bin/bash echo "Enter Username" read Username awk -F: -v var=${Username} '/^var:/... (9 Replies)
Discussion started by: Nostyx
9 Replies

5. Shell Programming and Scripting

Passing string as variable(s) in bash

I'm trying to write a basic bash script that takes input you give (what directory, if any, what name, if any ....) and passes the information to find. I'm trying to just create a string with all variables and then pass it to find. So far I have this extremely simple: #!/bin/bash -f ... (2 Replies)
Discussion started by: Starting_Leaf
2 Replies

6. Shell Programming and Scripting

How to change Linux Terminal environment variable in a perl or bash script?

Hi, I meet an problem that it cannot change Terminal environment variable in a perl or bash script. This change can only exist and become effective in script lifetime. But I want to make this change take effect in current opened Terminal. In our view, the thought seems to be impossible, As... (9 Replies)
Discussion started by: weichanghe2000
9 Replies

7. Shell Programming and Scripting

Passing string from SQL to a BASH script

OS Solaris 10, DB oracle 10g Hello, We currently have a BASH script that runs and moves image files from a remote server to the local db server. A snippet of the code shows that we are picking up all Images that are 'mtime -1' some code... for file in `ssh user@10.200.200.10 'find... (3 Replies)
Discussion started by: JonP
3 Replies

8. Shell Programming and Scripting

Passing arguments to a bash script

Hi, I wanted to pass an argument to a bash script. So that the argument is used inside the awk command inside the bash script. I know the noraml way of passing argument to a bash script as below : sh myScript.sh abc Inside the bash script i can use like this myArg1=$1 wc $myArg But... (8 Replies)
Discussion started by: shree11
8 Replies

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

10. Web Development

Passing variable from PHP to bash script

I am totally new to PHP and I am trying to create a script that will as a user for a hostname and then use the "hostname" variable to generate a report using REST API. I am able to create the html script and php script to GET the "hostname" but I am having trouble passing the hostname variable... (10 Replies)
Discussion started by: kieranfoley
10 Replies
SPEEDY(1p)																SPEEDY(1p)

NAME
speedy - a persistent Perl interpreter SYNOPSIS
speedy [ <perl options> ] [ -- <speedy options> ] [ <filename> ] DESCRIPTION
speedy, short for SpeedyCGI, is a way to run perl scripts persistently, which can make them run much more quickly. The most common way to make a script run persistently is by changing the interpreter line at the top of the script from: #!/usr/bin/perl to #!/usr/bin/speedy After the script is initially run, instead of exiting, the perl interpreter is kept running. During subsequent runs, this interpreter is used to handle new executions instead of starting a new perl interpreter each time. A very fast frontend program, written in C, is exe- cuted for each request. This fast frontend then contacts the persistent Perl process, which is usually already running, to do the work and return the results. Each perl script runs in its own Unix process, so one perl script can't interfere with another. Command line options can also be used to deal with programs that have memory leaks or other problems that might keep them from otherwise running persistently. Although SpeedyCGI is especially useful for CGI scripts, it can be used to keep any perl script running persistently. See CGI::Speedy- CGI(3.pm) for a complete description of SpeedyCGI, including further details on CGI execution and Apache issues. This manual page is based on that, but concentrates on running speedy from the command line. OPTIONS
The speedy command line is the same as for regular perl, with the exception that SpeedyCGI specific options can be passed in after a "--". For example the line: #!/usr/bin/speedy -w -- -t300 at the top of your script will set the perl option `-w' and will pass the `-t' option to SpeedyCGI, setting the Timeout value to 300 sec- onds. The options can also be set at run-time from the perl script using the CGI::SpeedyCGI module. OPTIONS AVAILABLE See CGI::SpeedyCGI(3.pm) for a complete description of the options. -p<string> BackendProg : Path to the speedy backend program. (Default: /usr/bin/speedy_backend) -B<number> BufsizGet : Use <number> bytes as the maximum size for the buffer that receives data from the perl backend. (Default: 131072) -b<number> BufsizPost : Use <number> bytes as the maximum size for the buffer that sends data to the perl backend. (Default: 131072) -g<string> Group : Allow a single perl interpreter to run multiple scripts. See CGI::SpeedyCGI(3.pm) for details. (Default: `none') -M<number> MaxBackends : If non-zero, limits the number of speedy backends running for this perl script to <number>. (Default: 0) -r<number> MaxRuns : Once the perl interpreter has run <number> times, re-exec the backend process. Zero indicates no maximum. This option is useful for processes that tend to consume resources over time. (Default: 500) -t<number> Timeout : If no new requests have been received after <number> seconds, exit the persistent perl interpreter. Zero indicates no timeout. (Default: 3600) -T<string> TmpBase : Use the given prefix for creating temporary files. This must be a filename prefix, not a directory name. (Default: `/tmp/speedy') -v Version : Print the SpeedyCGI version and exit. ENVIRONMENT
Environment variables can also be used to pass in options. This can only be done before the initial execution, not from within the script itself. The name of the environment variable is always SPEEDY_ followed by the option name in upper-case. For example to set the speedy Timeout option, use the environment variable named SPEEDY_TIMEOUT. FILES
/tmp/speedy* A unix socket used to connect to the backend process. See speedy_backend(1) for more information. AUTHOR
Sam Horrocks http://daemoninc.com sam@daemoninc.com NOTES
This manual page was created by Niko Tyni <ntyni@iki.fi> for Debian GNU/Linux, because the original program does not have one. It is based on the original and more complete CGI::SpeedyCGI(3pm) manual page. BUGS
There are command-line parsing incompatibilities with the real Perl. These aren't very easy to fix, as even the perlrun manpage isn't quite accurate on which parameters can be separated (like '-I') and which can't (like '-C'). speedy doesn't allow any of them to be sepa- rated. It considers the first option without a leading dash as the script filename. SEE ALSO
perl(1), CGI::SpeedyCGI(3pm), speedy_backend(1) SPEEDY(1p)
All times are GMT -4. The time now is 06:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy