473,385 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

error handling...

58
Hey friends
i just wrote some code that finds a zip file in a folder, unzips it using system() call to winzip32.exe.
the contents of zip is an oracle dmp file. I next use another system() call to oracles imp command to import the dmp file to a schema in oracle. It works just fine. What I need to do now is copy the contents of the shell window output to a text file so that i can look later to see if it worked correctly..

Expand|Select|Wrap|Line Numbers
  1. use warnings;
  2. use strict;
  3.  
  4.  
  5. my $InDir="D:\\temp";
  6. my @TempDir;  
  7.   opendir(DIR, $InDir) or die "Unable to open dir $InDir: $!\n";
  8.   @TempDir = reverse sort readdir(DIR);
  9.   my $tmp_dir = $TempDir[2];
  10.   close(DIR);
  11.   #$tmp_dir is now the most recent t.com archive 
  12.  
  13. my $winzip="C:\\Progra~1\\WinZip\\winzip32\.exe -min -e -o $InDir\\$tmp_dir $InDir";
  14.  
  15. func1();
  16.  
  17. my @TempDir2;  
  18.   opendir(DIR, $InDir) or die "Unable to open dir $InDir: $!\n";
  19.   @TempDir2 = reverse sort readdir(DIR);
  20.   my $tmp_dir2 = $TempDir[3];
  21.   close(DIR);
  22.   #$tmp_dir2 is now the most recent unzipped t.com archive
  23.  
  24. my $oracle="imp user/password\@instance FROMUSER=fuser TOUSER=tuser FILE=$InDir\\$tmp_dir2 TABLES=($tmp_dir2) FEEDBACK=1000000 LOG=$InDir\\logs\\$tmp_dir2\.log";
  25.  
  26.  
  27. func2();
  28.  
  29. sub func1{
  30.   system "$winzip";
  31. }
  32.  
  33. sub func2{
  34.   system "$oracle";
  35. }
when i run in a cmd window here are the messages i get as the perl script runs

D:\data\scripts>test.pl

D:\data\scripts>
C:\Progra~1\WinZip\winzip32.exe -min -e -o D:\temp\TMP2.zip D:\temp

D:\data\scripts>
imp user/password@instance FROMUSER=fuser TOUSER=tuser FILE=D:\temp\TMP2.dmp TABLES=(TMP2) FEEDBACK=1000000
LOG=D:\temp\TMP2.dmp.log

Import: Release 10.2.0.1.0 - Production on Thu Apr 24 15:14:17 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit
Production
With the Partitioning, OLAP and Data Mining options

Export file created by EXPORT:V10.02.01 via conventional path
import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing USER's objects into USER
. . importing table "TMP2"
477438 rows imported
Import terminated successfully without warnings.


so is it possible to have that all exported out to a text file?
Thanks ahead of time
Apr 24 '08 #1
2 2481
nithinpes
410 Expert 256MB
You can just redirect the output to a file on command line. You can do this either using system command or using reverse quotes.

Using system() command:
Expand|Select|Wrap|Line Numbers
  1. sub func1{
  2.   system("$winzip >D:\output.txt");
  3. }
  4.  
  5. sub func2{
  6.   system("$oracle >>D:\output.txt");
  7. }
  8.  
Using reverse quotes:
Expand|Select|Wrap|Line Numbers
  1. open(OUT,">D:\\output.txt");
  2. @out1=`$winzip`;
  3. @out2=`$oracle`;
  4. print OUT @out1;
  5. print OUT @out2;
  6. close(OUT);
  7.  
Apr 25 '08 #2
Mohanj
2
Please check the below url for
export & import tables in 10g using shell script

http://techieidea.blogspot.com/2009/...les-using.html
Nov 23 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: WSeeger | last post by:
When creating a new class, is it encouraged to always include error handling routines within your LET and GET procedures? It's seems that most text books never seem to include much about error...
12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
3
by: Stefan Johansson | last post by:
Hi all I'am moving from Visual Foxpro and have a question regarding "best practice" error handling in vb .net. In VFP I have always used a "central" error handling object in order to have a...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
9
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.