How to call the System command twice in the same perl script...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call the System command twice in the same perl script...
# 1  
Old 04-14-2011
How to call the System command twice in the same perl script...

Hello experts,
I have a perl script which looks for the ARGV and then loads the data as per it.
Example.
Code:
#Checking the server to connect
if ($ARGV[0] eq 'QA')
{
        $ENV{"ORACLE_HOME"} = "/oracle/product/11.2.0";
        $ENV{"PATH"} = "$ENV{'PATH'}:/oracle/product/11.2.0/bin";
        $ENV{"ORACLE_SID"} = "db112";
        #$dbsid = 'db111';
        $dbuser = 'zx####';
        #$dbpwd = `/usr/local/pl/perlencrypt.pl -k /kda1/system/ealgorithm -d /sdr1/system/db111zx####pw`;
}

Now i want to add the same for Prod, which i did;
Code:
#Checking the server to connect
if ($ARGV[0] eq 'QA')
{
        $ENV{"ORACLE_HOME"} = "/oracle/product/11.2.0";
        $ENV{"PATH"} = "$ENV{'PATH'}:/oracle/product/11.2.0/bin";
        $ENV{"ORACLE_SID"} = "db112";
        #$dbsid = 'db222';
        $dbuser = 'zx####';
        #$dbpwd = `/usr/local/pl/perlencrypt.pl -k /kda1/system/ealgorithm -d /sdr1/system/db222zx####pw`;
}

But the problem here is, i am using "system" command to call the sqlldr to load the data into QA tables.
Code:
$infile = $inputdirectory.$file;
print $infile;
#Logfile location where it will reside
$logFile = "/A/B/C/log/ZIP_code.log";
#Control file location
$confile = "/A/B/C/control/zip_codes_38.ctl";
print "$dbuser\n";
#print "$dbpwd\n";
system ("/usr/local/pl/perlencrypt.pl -k /kda1/system/ealgorithm -d /sdr1/system/db111zx####pw | sqlldr userid=$dbuser DATA=$infile control=$confile log=$log
File");

#This is the system command to call Sqlldr for Production.
system ("/usr/local/pl/perlencrypt.pl -k /kda1/system/ealgorithm -d /sdr1/system/db222zx####pw | sqlldr userid=$dbuser DATA=$infile control=$confile log=$log
File");[/CODE]
Can i use the same "System" command for Prod too? Will that work...?
Or, How should i use another ARGV for Production in the same perl script?
# 2  
Old 04-15-2011
i believe you can either use system command or the backticks (`) operator to call the system commands
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

2. Shell Programming and Scripting

How to call a bash command from within a perl script?

In a bash script, one can call a perl command in the following manner, where "myperlcommand" is a perl command. perl -e 'myperlcommand(arguments)' perl -e 'print("UUUU"x4)' Now, how can one call a bash command from within a perl script? (Suppose that mybashcommand is a bash... (1 Reply)
Discussion started by: LessNux
1 Replies

3. Shell Programming and Scripting

Perl - Call a sub routine in a command

Hi all I have written a simple perl script that has different options i.e. myscript -l -p etc i have it so when it runs without any switches it runs a subroutine called nvrm_norm i want to be able to do a -p option and run pall -w -f and then called the subruotine pall is... (1 Reply)
Discussion started by: ab52
1 Replies

4. Shell Programming and Scripting

Running a script in system() call and want the script's output

Hi All, I have a script(sample.sh) displaying the output of "dd" command. Now i am using this script in system() call as, system("sh sample.sh") in an application file. I want the output of system("sh sample.sh") in the application file itself. How can i get it? Many thnaks.... (9 Replies)
Discussion started by: amio
9 Replies

5. Programming

how to call dot c file using system command

Hi every one, i have to dot pc files. One have main function but one dont have.I have to call dot pc file using system () cmd.File is being call have main function.Please let me know how i can call .pc file with two arguments from other dot pc file.I want some thing like sprintf(buf, "ss_xxx.pc... (4 Replies)
Discussion started by: goraya430
4 Replies

6. Shell Programming and Scripting

how to call dot c file using system command

Hi every one, i have to dot pc files. One have main function but one dont have.I have to call dot pc file using system () cmd.File is being call have main function.Please let me know how i can call .pc file with two arguments from other dot pc file.I want some thing like sprintf(buf,... (1 Reply)
Discussion started by: goraya430
1 Replies

7. Shell Programming and Scripting

[Perl] Capture system call error message.

Hi, I googled a bit, but could not find the answer to my problem. But I am sure it is a common issue. I have this code: #!/bin/perl -w #-d use strict; sub remsh_test() { my $host = $_; printf "\n----\n\n"; printf "remsh to $host with system call\n"; my $result = system... (3 Replies)
Discussion started by: ejdv
3 Replies

8. Programming

Need help with running the tar command using system() call in C

Hey everyone, I've been trying to use the system(cmd) call in C to tar multiple files together. When i do so i specify the absolute paths of the tar file as well as the files to be included in the tar file. Eg: system("tar -cf /tmp/example.tar /mnt/john/1.xml"); system("tar -uf... (5 Replies)
Discussion started by: vsanjit
5 Replies

9. UNIX for Dummies Questions & Answers

how can call perl script as command?

Hello say i have written some perl scripts , now i like to call them in my unix shell as unix command like "more" , "ls" , "grep" so that my say perl script called "foo.pl" will be called from every where as "foo" or "foo arg1 arg2"? Thanks (1 Reply)
Discussion started by: umen
1 Replies

10. UNIX for Dummies Questions & Answers

a system call for sed in a awk script

Hi, this is my test file : DELETE FROM TABLE WHERE ID_INTERNAL = :TABLE.ID-INTERNAL, ID-INTERNAL-CRAZY ID-INTERNAL-OPEN ID-INTERNAL /ID-INTERNAL/ I want all occurences of ID-INTERNAL replaced with a one, if ID-INTERNAL has and dash afer it , dont replace it example:... (6 Replies)
Discussion started by: seaten
6 Replies
Login or Register to Ask a Question