03-27-2011
Passing perl variable to shell command
Can we pass perl variable to shell commands. If yes, please give some example.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
2. Shell Programming and Scripting
Solaris 10
Korn shell ksh,
Hi there,
I have figured out to get yesterday's date which is using the below command:
TZ=GMT+24; date +%d-%b-%Y to get the format of 30-Sep-2008 and
TZ=GMT+24; date +%Y%m%d to get the format of 20080930.
I need this two format. In my perl script below I need... (4 Replies)
Discussion started by: bulkbiz
4 Replies
3. UNIX for Advanced & Expert Users
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
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
Hi,
I would like to use a shell variable $amp in my perl command line.
for fa in $WORKSPACE/*.fa; do
amp=`grep ">.*" $fa | sed -e's#>\(.*\)#\1#g'`
ampsam="$WORKSPACE/$base/$base.$amp.sam"
sqheader=`grep "^@SQ.*SN:$amp.*" $sam`
printf "$sqheader\n" >> $ampsam
... (3 Replies)
Discussion started by: jdilts
3 Replies
7. Shell Programming and Scripting
Hi all,
I have a file looks like
AAAA 111
BBBB 222
CCCC 333
need to pass variable value like var1=AAAA and var2=111
to another command for three times with next values.
stuck over here
cat file | while read line
do
export var1=`awk '{print $1}'`
echo $var1
export var2=`cat file... (3 Replies)
Discussion started by: rakeshtomar82
3 Replies
8. Shell Programming and Scripting
Hi,
I have a shell script, In which i have variable "var1" and some perl command inside shell script.
export var1='coep -n rst-a2p-hinje.vci.all.com -c'
perl -pi -e 's/^/coep -n rst-a2p-hinje.vci.all.com -c /' command.txt
currently I am adding value of var1 in command.txt file by... (2 Replies)
Discussion started by: rakeshtomar82
2 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
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
LEARN ABOUT DEBIAN
devel::repl::profile
Devel::REPL::Profile(3pm) User Contributed Perl Documentation Devel::REPL::Profile(3pm)
NAME
Devel::REPL::Profile - code to execute when re.pl starts
SYNOPSIS
package Devel::REPL::Profile::MyProject;
use Moose;
use namespace::clean -except => [ 'meta' ];
with 'Devel::REPL::Profile';
sub apply_profile {
my ($self, $repl) = @_;
# do something here
}
1;
DESCRIPTION
For particular projects you might well end up running the same commands each time the REPL shell starts up - loading Perl modules, setting
configuration, and so on.
A mechanism called profiles exists to let you package and distribute these start-up scripts, as Perl modules.
USAGE
Quite simply, follow the "SYNOPSIS" section above to create a boilerplate profile module. Within the "apply_profile" method, the $repl
variable can be used to run any commands as the user would, within the context of their running "Devel::REPL" shell instance.
For example, to load a module, you might have something like this:
sub apply_profile {
my ($self, $repl) = @_;
$repl->eval('use Carp');
}
As you can see, the "eval" method is used to run any code. The user won't see any output from that, and the code can "safely" die without
destroying the REPL shell. The return value of "eval" will be the return value of the code you gave, or else if it died then a
"Devel::REPL::Error" object is returned.
If you want to load a "Devel::REPL" plugin, then use the following method:
$repl->load_plugin('Timing');
The "load_plugin" and "eval" methods should cover most of what you would want to do before the user has access to the shell. Remember that
plugin features are immediately available, so you can load for example the "LexEnv" plugin, and then declare "my" variables which the user
will have access to.
Selecting a Profile
To run the shell with a particular profile, use the following command:
system$ re.pl --profile MyProject
Alternatively, you can set the environment variable "DEVEL_REPL_PROFILE" to MyProject.
When the profile name is unqualified, as in the above example, the profile is assumed to be in the "Devel::REPL::Profile::" namespace.
Otherwise if you pass something which contains the "::" character sequence, it will be loaded as-is.
AUTHOR
Matt S Trout - mst (at) shadowcatsystems.co.uk (<http://www.shadowcatsystems.co.uk/>)
LICENSE
This library is free software under the same terms as perl itself
perl v5.14.2 2012-06-02 Devel::REPL::Profile(3pm)