473,671 Members | 2,442 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.(inc luding 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 2152
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
3037
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
1928
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 average has 20 properties. What would be the best way to implement such a thing? The book I am reading uses templated controls and basically reconstructs the entire hierarchy everytime page is accessed based on the tags in the .aspx file, but...
8
5810
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 would like to support. During the code generation phase, I add an "Implements Ixxx" for each interface they select, but I've not yet figured out how to add the skeleton implementation for those interfaces. Once the user opens the class in the VS...
0
2253
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 assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
9
5439
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 be able to generate and compile the project on the enviroments where Visual Studio.Net is not installed. Thanks and Regards, Anubhav Jain MTS Persistent Systems Pvt. Ltd. Ph:+91 712 2226900(Off) Extn: 2431 Mob : 094231 07471
2
8034
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: fopen(gen_pdf/gen_pdf/yan.pdf) : failed to open stream: No such file or directory in /export/home/.../pdfCov/fpdf.php on line 1698 FPDF error: Unable to create output file: gen_pdf/yan.pdf " I cut and paste the following part of the code into a test.php file and
3
2063
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 an XML document structure based on an XML file as input. I have to build some classes that allow me to generate some very complex/large/nasty XML documents for use in B2B exchange of data (like
6
2708
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 parameters that I keep changing. this way it saves the pain of having to back up the output file and rename it before running the program again.
7
3130
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 simple solution but for some reason i can't seem to figure it out. So any help would be very kind. Here is the code for my recent attempt. // connection to the database $dbhandle = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die("Unable...
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8824
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8603
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.