473,513 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

to generate the output in a log file

2 New Member
Hi.. I have written a perl script for displaying the difference between two directory structures.(including the diffferences in the files)
I have to generate the output in a log file.

Expand|Select|Wrap|Line Numbers
  1. #!usr/local/bin/perl -w
  2. use Test::More tests => 5;
  3. use Test::Files;
  4. use File::Spec;
  5.  
  6. my $logging = "file";
  7.  
  8. if ($logging eq "file") {
  9.     open LOG, ">output.log" or die $!;
  10.     select LOG;
  11. }
  12.  
  13. print "\nEnter the first folder name\n";
  14. my $dir1 = <STDIN>;
  15. chomp($dir1);
  16.  
  17. print "\nEnter the second folder name\n";
  18. my $dir2 = <STDIN>;
  19. chomp($dir2);
  20.  
  21. compare_dirs_ok($dir1,$dir2,"REPORT1");
  22. compare_dirs_ok($dir2,$dir1,"REPORT2");
  23.  
  24. select STDOUT;
  25.  
I have tried changing the FileHandle to LOG file. But its not working in the function compare_dirs_ok()
can any1 suggest something for generating the output in a log file instead of standard output.
Jul 12 '07 #1
1 2143
numberwhun
3,509 Recognized Expert Moderator Specialist
I am going to assume that you are running this on a Unix system since your shebang references a Unix based path. Not to bypass a coded solution, but have you tried setting your standard out and standard error to a log file as you execute the script?

ie:
Expand|Select|Wrap|Line Numbers
  1.        /path/to/perl/script.pl   >output.log  2>&1
  2.  
This will execute your script and send standard output to "output.log". In addition, it will take standard error(2) and output it to the same place as standard out (1). If you want the errors to go someplace else, then replace the "&1" with the path to the errors log file.

Regards,

Jeff
Jul 12 '07 #2

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

Similar topics

3
3020
by: Mike | last post by:
I am just wondering if it is possible to save a HTML string from PHPs? Let me elaborate more on what I mean. If you do <?php include 'abc.php' ?> //abc.php <html>
3
1916
by: Dennis M | last post by:
Hey everyone, I am curious what the performance impact of a custom control would be if it had a significant hierarchy of children. For example, 40 child controls, 5 levels deep, each control on...
8
5795
by: Bill Rust | last post by:
I've created an "Add Item" wizard for VB.NET 2003 that allows a user to add a specialized class that works with my application framework. In the wizard, the user can select the interfaces they...
0
2236
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
9
5422
by: Anubhav Jain | last post by:
Hi, I am having few .net source files(.cs or .vb) and I want to dynamically generate the corresponding .net project file(.csproj or .vbproj) for them without using visual studio.So that I could...
2
8026
by: yanlu06 | last post by:
I tried to use HTML2FPDF to generate dynamic local files and save the generated files on the server. I don't know why it gives me the following error message: " Warning:...
3
2045
by: joshblair | last post by:
Hello, Has anyone ever seen or created such a code generator? I'm looking for a sample of a code generator that will generate code (preferably one that uses C# and the XMLTextWriter) to create...
6
2697
by: Freddy | last post by:
Hi all, I use a C program to generate lots of data while changing many parameters sometimes. However, I am trying to find a way to let C generate the output file names dependent on a few...
7
3122
by: Gfmultimediadesigns | last post by:
Hello, I'm attempting to generate an xml file through php which pulls from two seperate tables in a single database. I will be the first to admit that I am still learning and it is probably a very...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1591
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.