Help needed in calling path file from Perl script.


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in calling path file from Perl script.
# 1  
Error Help needed in calling path file from Perl script.

Hi All,
I need help in accessing a path file (path.xyz_pqr) not having a shell shebang and exporting paths in the following syntax,

export DB_SCRIPT_PATH="/abc/aash/scripts/db_scripts/xyz_pqr"
export SRC_FILES_DIR="/bcd/fdw/incoming/xyz_pqr"

I need to use the path contained in the DB_SCRIPT_PATH variable.
Tried using system, `` and exec also referred to earlier posts like

https://www.unix.com/shell-programmin...ent-shell.html
but could not get it working. Smilie
The path.xyz_pqr file works when called using ./path/of/path.xyz_pqr file on the command prompt but not through my perl script.
I am currently working on /usr/bin/sh shell. Please help m ein calling this path file in my Perl script and using the DB_SCRIPT_PATH variable in my Perl script for getting the path stored in it.
Thanks Smilie
# 2  
If you need to set env vars in your perl script , try:
Code:
use Env;
$ENV{DB_SCRIPT_PATH}="/abc/aash/scripts/db_scripts/xyz_pqr"
$ENV{SRC_FILES_DIR}="/bcd/fdw/incoming/xyz_pqr"

# 3  
Question

Quote:
Originally Posted by Klashxx
If you need to set env vars in your perl script , try:
Code:
use Env;
$ENV{DB_SCRIPT_PATH}="/abc/aash/scripts/db_scripts/xyz_pqr"
$ENV{SRC_FILES_DIR}="/bcd/fdw/incoming/xyz_pqr"


If i need set the Env vars in the Perl script itself then what is the use of exporting it from the Path file? Need to get the values of exported variables into the Perl script.

I think my system calls are not working fine....need help with that...
Smilie
# 4  
Reverse logic:
Code:
# export MY_VAR="test_var"

Code:
#cat test.pl
#!/usr/bin/perl
use Env;
print "VAR:".$ENV{MY_VAR}."\n";

Code:
# test.pl                 
VAR:test_var

# 5  
Error

Quote:
Originally Posted by Klashxx
Reverse logic:
Code:
# export MY_VAR="test_var"

Code:
#cat test.pl
#!/usr/bin/perl
use Env;
print "VAR:".$ENV{MY_VAR}."\n";

Code:
# test.pl                 
VAR:test_var


Hey Klashxx...I fully agree with the concept that you have used here but i need to call an already existing file that exports these path variables. I just need to call that file.

I need help with calling this file path.xyz_pqr with variables getting exported in it.
Replies are highly appreciated.
Thanks.
# 6  
Error Calling a shell script with paths from a Perl script.

I am using hardcoded values for time being but have to get the path variables from the file having Paths dclared in variables.

Need help... please let me know in case any further details are needed.

Thanks.
# 7  
A possible workaround inside your perl:

->Read your profile file -> Look for the export VAR=VALUE pattern ->
->Get the var & values to be imported and use ENV .
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #619
Difficulty: Medium
In Python, variables may not be used by just assigning them a value. Declaration and data type definition is required in Python.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script for Calling a function and writing all its contents to a file

I have a function which does awk proceessing sub mergeDescription { system (q@awk -F'~' ' NR == FNR { A = $1 B = $2 C = $0 next } { n = split ( C, V, "~" ) if... (3 Replies)
Discussion started by: crypto87
3 Replies

2. Shell Programming and Scripting

calling a shell script present on another server using perl script.

Hi, I am working on a sever A. I want to write a perl script to execute a shell script persent on the server B. please help me in this. thanks in advance. (3 Replies)
Discussion started by: anandgodse
3 Replies

3. Shell Programming and Scripting

How we can pass the argument when calling shell script from perl script

Can someone let me know how could I achieve this In one of per script I am calling the shell script but I need to so one thing that is one shell script call I need to pass pne argument.In below code I am calling my ftp script but here I want to pass one argument so how could I do this (e.g:... (5 Replies)
Discussion started by: anuragpgtgerman
5 Replies

4. Shell Programming and Scripting

calling a perl script with arguments from a parent perl script

I am trying to run a perl script which needs input arguments from a parent perl script, but doesn't seem to work. Appreciate your help in this regard. From parent.pl $input1=123; $input2=abc; I tried calling it with system("/usr/bin/perl child.pl $input1 $input2"); and `perl... (1 Reply)
Discussion started by: grajp002
1 Replies

5. Shell Programming and Scripting

Calling a Perl script in a Bash script -Odd Situation

I am creating a startup script for an application. This applications startup script is in bash. It will also need to call a perl script (which I will not be able to modify) for the application environment prior to calling the application. The problem is that this perl script creates a new shell... (5 Replies)
Discussion started by: leepet01
5 Replies

6. Shell Programming and Scripting

calling a php file from perl script..

Hi am new to perl script .. i need some useful tutorials links to learn perl script.. and a sample script to call a php file from perl script.. thanks.. (3 Replies)
Discussion started by: senkerth
3 Replies

7. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

8. Shell Programming and Scripting

Calling 3 perl script from one

hi all, I have 3 perl scripts a.pl,b.pl and c.pl each of these work when i pass a date for eg: perl c.pl 2010-05-27 now i want to write a perl script that would call the 3 scripts and make it run all the 3 scripts (a.pl,b.pl,c.pl) parallelly rather than 1 after the other....... pls... (2 Replies)
Discussion started by: siva_nagarajan
2 Replies

9. Shell Programming and Scripting

Simple Script needed for Processing CSV file perl

I am new to perl, and need a script to pull a CSV file, strip out 2 leading columns, and 2 ending columns, and resave the file in a new location. The file is basic and has less than 10,000 records. Secondly, can I schedule perl scripts to run daily? Can someone provide the basic script to... (1 Reply)
Discussion started by: cobbjob
1 Replies

10. Shell Programming and Scripting

Help needed in function calling in a script

:confused:Hi , I have a script as shown below: rpttxt() { name="$*" awk '/'"${name}"'/ {print $2 $3"=" $4}' file.txt } xx = rpttxt "COL_HEAD_1" awk 'BEGIN {printf("%36s \n ","'"$xx"'")}' rpttxt() is a function..I want to store the final result of this function in... (3 Replies)
Discussion started by: jisha
3 Replies

Featured Tech Videos