Export from perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Export from perl script
# 1  
Old 01-17-2011
Export from perl script

Hi,

Want to initaite the Oracle's Export utility from the perl script,but getting error as mentioned below:

Script
Code:
#!/usr/bin/perl -w
my $username="system";
my $password = "manager";
my $tns = "DBLOCAL";
 
exp $username/$password@$tns

Error
Code:
$ ./testexp.pl
Array found where operator expected at ./testexp.pl line 6, at end of line
(Missing operator before ?)
syntax error at ./testexp.pl line 6, near "$password@"
Execution of ./testexp.pl aborted due to compilation errors.

What mistake is done ?

Regards

Last edited by Scott; 01-17-2011 at 10:02 AM.. Reason: Code tags, please...
# 2  
Old 01-17-2011
exp is not valid perl.
My suggestings in red, below:
Code:
#!/usr/bin/perl -w

use strict;

my $username = "system";
my $password = "manager";
my $tns = "DBLOCAL";

system "exp $username/$password\@$tns";

This will run exp, but toss its output into the the bit-bicket. If you want to read what exp generated:
Code:
open FH, '-|', "exp $username/$password\@$tns";
while (<FH>) {
    tbd
}
close FH;


# 3  
Old 01-18-2011
Hi,

I tried as per your suggestions, but unfortunately didnt worked out. On executing the perl script Export command gets started, but asks for the parameters which are already specified with the commands. Actually script should execute without asking for the parameters.

Code:
my $schemaname = "TEST";
my $password = "password";
my $tns = "dblocal";
my $filepath = "c:/";
my $filename = "EXP_".$schemaname".dmp";
my $username = "SYSTEM";

system "exp $username/$password\@$tns file=$filepath$filename owner=$schemaname";

Script ask for the parameters (Enter array fetch buffer size) as below which it should not as it should take default value of it.

Quote:
Export: Release 9.2.0.8.0 - Production on Tue Jan 18 12:10:30 2011

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to: Oracle9i Release 9.2.0.8.0 - Production
JServer Release 9.2.0.8.0 - Production
Enter array fetch buffer size: 4096 >
# 4  
Old 01-18-2011
Try evaluating the variables

Code:
system "exp ${username}/${password}\@$tns file=${filepath}${filename}owner=${schemaname}";

# 5  
Old 01-18-2011
It seems you have a problem with env variables, try to load the profile first , something like:

Code:
$cmd=". /path/to/profile;exp ${username}/${password}\@$tns file=${filepath}${filename} owner=${schemaname}";

system($cmd);

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Export Error in Shell script

All, While executing the bellow commnad after the sed, awk command to export the value to, i am getting the fallowing error. line="_AABBB.EEEEEEE.LOG4JDISPLAY.PATH_=/apps/opt/abcde/pdstdsd/esapp/apadsfasdf/logadsfasdf.xml" keystring=`echo $line | awk -F"=" '{ print $1 }'`... (1 Reply)
Discussion started by: jothi basu
1 Replies

2. Shell Programming and Scripting

export repository shell script

Hi Forum, I have script to export he Siebel repository. My requirment is to have a shell script in place so when placed in it in a cron it should generate the repsoitory dat file on date basis. Script for export: repimexp /a E /c UCM_ES_DEV2_DSN /u sadmin /p SADMIN /d siebel /r... (4 Replies)
Discussion started by: nuthakki
4 Replies

3. Shell Programming and Scripting

Script for Export backup!!

Dear Team, Can you please help me to write the script for export backup. I've written some of the part and stuck in "if" condition Apprecatied if you help me. Requirement:- Export backup completion sent the email if it is success (sent backup success email)or if fails (sent backup fails... (9 Replies)
Discussion started by: Mohammed Fareed
9 Replies

4. UNIX for Dummies Questions & Answers

Export script to current session

Hi, I have a script called bash$> cat -ev setprofile.sh alias rm='rm -i'$ $ The alias does not take effect unless i run the script as bash$> . ./setprofile.sh What do I have to do in-order to simply run (9 Replies)
Discussion started by: shifahim
9 Replies

5. Shell Programming and Scripting

Use of export from a shell script..

Hi All, I am facing a problem while trying to export path variables from a script. Here's my situation 1. I have a script in which i have defined all the path variables to be exported: export ORACLE_HOME=/path/to/bin/ export NG_USER_HOME=/path/to/bin/ etc.... 2. I have another shell... (4 Replies)
Discussion started by: raghu_shekar
4 Replies

6. Shell Programming and Scripting

How to export an array to perl script?

hi all...... i want to use an array ,declared in bash, in embedded perl script. is there any way to export whole array so that i can use it '$ENV{}' or something.. thanx in advance!! regards, prayush (1 Reply)
Discussion started by: tprayush
1 Replies

7. Shell Programming and Scripting

script to export variables

Hi, I am a newbie to unix as well as scripting. I need to write a script, which on execution sets the necessay oracle variables. Can someone help me out as to how to proceed? also can u suggest good tutorial for bash/shell scripting? thanks (1 Reply)
Discussion started by: aboxilica
1 Replies

8. Shell Programming and Scripting

export equivalent command in PERL

Hi I need an equivalent command in PERL for the following. export LC_ALL=C; I hope this is the command. Please confirm this and correct me if i am wrong $ENV{LC_ALL}="C"; Thanks and Regards Ammu (1 Reply)
Discussion started by: ammu
1 Replies

9. UNIX for Advanced & Expert Users

export UNIX95=1 in a script??

Hi, I have following script. It has a line export UNIX95=1 What does UNIX95 suggest? If I donot export UNIX95=1 , I get error "illegale option -o" for ps command. man ps donot show -o option. Any pointers?? Thanks in advance, -Ashish (2 Replies)
Discussion started by: shriashishpatil
2 Replies

10. Shell Programming and Scripting

Perl: export variable to shell

Hi, I am running a series of scripts and I need to transport a particular variable across many scripts. I thougt of defining an environmental variable which I could access through. But I found that the variable dies as soon as the script ends.. Currently I write this variable to a temporary... (2 Replies)
Discussion started by: oldtrash
2 Replies
Login or Register to Ask a Question