Sponsored Content
Top Forums Shell Programming and Scripting Perl- Output file is always 0 byte Post 302433611 by amit1_x on Wednesday 30th of June 2010 06:00:59 AM
Old 06-30-2010
Perl- Output file is always 0 byte

Hi all,

I am new to perl programming. However i have a script that connects to the database and spools that into an output file.
Strange thing is that sometimes this script works and sometimes the ouput spool file is always 0 byte.
I have verified the sql query and the query always returns some value not sure why perl is not able to output this value to my spool file

- providing a Snapshot of my Code
Code:
open(Spool, "> $filename") or die "Error opening $filename\n";

while( $Conn->FetchRow() ) {

     my $Temp =$Conn->Data("STATUS");
     print "Value is $Temp";  --> $Temp has always some value in it
-- Approach 1
    print Spool $Temp; --> This does not work output file is 0 byte
--- Approach 2
    printf(Spool "%s\n", $Conn->Data("STATUS" )); --> This does not work output file is 0 byte
     }
     
   $Conn->Close();
   
   close Spool;


I have used a similar code before and their it seems to work

Code:
 open(Spool, "> $filename") or die "Error opening $filename\n";
  my $blank = "| ";
  my $lineCtr = 0;
  printf(Spool "****************Biztalk Check****************\n");
while( $Conn->FetchRow() ) {


    printf(Spool "\n%s %s %s %s\n",
    $Conn->Data("COMP"),
    $Conn->Data("SI"),
    $Conn->Data("num_swifts"),
    $Conn->Data("STATUS")
   );
     }
     
   $Conn->Close();
   
   close Spool;

Could anyone suggest what is wrong here ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut output to same byte position

Hi folks I have a file with thousands of lines with fixed length fields: sample (assume x is a blank space) 111333xx444TTTLKOPxxxxxxxxx I need to make a copy of this file but with only some of the field positions, for example I'd like to copy the sample to the follwing: so I'd like to... (13 Replies)
Discussion started by: HealthyGuy
13 Replies

2. Shell Programming and Scripting

formating array file output using perl

Hello, I am trying to output the values in an array to a file. The output needs to be formated such that each array value is left jusified in a field 8 character spaces long. Also, no more than 6 fields on a line. For example: @array= 1..14; Needs to be output to the file like so: 1 ... (4 Replies)
Discussion started by: seismic_willy
4 Replies

3. Shell Programming and Scripting

Append Output to another file in Perl

Hi All, I am writing a Perl script such that the output from "perl myscript.pl file1" to be appended to another file name called file2. I tried out with the below code but couldn't work. Can any expert give me some advice? open(OUTPUT, 'perl myscript.pl file1 |'); close OUTPUT;... (7 Replies)
Discussion started by: Raynon
7 Replies

4. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

5. Shell Programming and Scripting

perl redirect output to file ..not working

here is simple perl script i wanted for my net connection ... just to check if default gateway is pingable or not if not write in log file but problem is that i can not write in file i can print on STDOUT but not in file ...why so ?? same thing was there when i was tying to write on sockets... (7 Replies)
Discussion started by: zedex
7 Replies

6. Shell Programming and Scripting

Remove a byte(Last byte from the last line)

Hi All Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE. Please suggest me something. Thank's and regards Vinay (1 Reply)
Discussion started by: vinayrao
1 Replies

7. Shell Programming and Scripting

taking output in csv file from perl

Hi, I am new to perl I need to connect from linux server to oracle database and i need to query the database and take result into csv file. i try to do but i am getting this error: #!/usr/bin/perl use DBI; BEGIN { $ENV{ORACLE_HOME} = '/home/oracle/product/8.1.7'; ... (1 Reply)
Discussion started by: prakash.gr
1 Replies

8. Shell Programming and Scripting

Creating output file using Perl

As an simple example, I have the following files fin1.zv being a one column set of number 1 90 2 80 3 60 4 30 5 20 fin2.zv is another file like this 1 10 20 30 40 50 2 60 70 80 90 0 3 90 80 70 60 50 4 40 30 20 10 0 5 10 20 30 40 50 (2 Replies)
Discussion started by: kristinu
2 Replies

9. Programming

Mod Perl 2 with byte range help

I am writing a mod perl 2 download module and I am facing the same issue as this guy. mp2 / Apache byterange filter | ModPerl | ModPerl If I remove the check for EOS in byterange_filter.c and recompile Apache2, the byte range filter is executed and the result is correct but I am not sure that... (0 Replies)
Discussion started by: metalbone
0 Replies

10. Shell Programming and Scripting

Output after a perl script gives a file with size zero.

Hi, I have a unix shell script which generates a flat file after connecting to Teradata servers to fetch tables and views and also picks up modified unix scripts from the specified paths. Later on the script calls a perl script to assign a value based on the type of object in the flat file which... (2 Replies)
Discussion started by: yohasini
2 Replies
MAILHELP(1)						      General Commands Manual						       MAILHELP(1)

NAME
maildist, mailhelp, maillist, mailpatch - mailagent's commands SYNOPSIS
maildist address system [ version ] mailhelp [ address ] maillist [ address ] mailpatch address system version patchlist DESCRIPTION
These commands are not intended to be run directly by a user. They may appear in any mail whose subject is set to Command. Such a mail will be processed by the mailagent(1), which will extract all lines beginning with @SH, followed by one of the above commands. The mailagent first sets environment variables that will be used by every commands. Maildist is used to mail a whole distribution to the given address. The version number may be ommitted if the system has no version speci- fied !! Maildist looks for the Spool/distribs file to find where the distribution is located. If it has been archived, the file name extension is used to guess how the archive will be restored: .cpio archive is a cpio archive .tar archive is in tar format .cpio.Z compressed cpio archive .tar.Z compressed tar archive Note that on file systems with short file names, the final .Z extension could be dropped. Therefore, compressed archives must be explicitely stated in the Spool/distribs file. Once the directory is found (or extracted), maildist looks for a .package file. If one is found, then it is assumed this distribution is under control of the dist 3.0 package, and the makedist commmand is called to actually mirror the source tree (makedist being part of dist 3.0). Otherwise, it looks for a MANIFEST file. If it finds one, only the files listed therein will be sent. Otherwise, all the files will be sent, excepted the binary executables and object files, the RCS sub-directories or RCS files, the private U subdirectory and the .package file, any core file or files in a bugs subdirectory. Then, the following algorithm is used: if no RCS file is found, the file is sent as-is. Otherwise, we look for a defined 'lastpat' symbol. If it is found, the corresponding revision is checked-out and sent. Otherwise, the last-revision on the default branch is exctracted, pro- vided that the corresponding working file is not found. The maildist command will not work if the system is tagged as an old one (with an o in the patches column of the distribs file). A message will be sent back to the user, explaining that only patches are available. Mailhelp sends help to the address (if ommitted, the return path of the mail is used). The help text is found in Spool/agenthelp. It should have been correctly set in the installation procedure, as explained in the mailagent(1) manual page. Maillist sends the list of available distributions, with current patchlevels if necessary. The Spool/distribs and Spool/proglist files are both used to build the list. Mailpatch sends one or more patches for a maintained distribution. The directory or the archive is found by scanning Spool/distribs. The bugs sub-directory must then hold the available patches. The patches may be stored in compressed form (with the ending .Z), as mailpatch knows about them and will uncompress the patch before sending. Patches for old systems are kept in a separate directory, either in normal or in compressed form. If the version number of the old system is x.y, then the directory must be named bugs-x.y and placed in the root directory of the system, just like bugs is. Whenever the user asks for an old system, mailpatch inserts a little note giving the latest version number for that system. NOTE
For a more accurate description of these commands (user's point of vue), you may want to have a look at the help file or send help to your- self using the mailhelp command. FORWARDING
When the author of a package wishes to relinquish all maintenance duty, he is most often stuck by the weight of the past: Configure scripts have his e-mail address hardwired (see unit MailAuthor.U) and Command messages for package registration and/or patch requests will continue to reach him. The answer to that is to leave a .forward file at the top of the package tree and commands will automatically forge new requests and for- ward them to the address listed in the .forward file. Now the recipient surely needs a mailagent at the other end to deal with forwarded requests! Only plain e-mail address(es) are allowed in the .forward. The "|command" processing hook is not supported, since it's not sendmail which interprets that file but the command itself. Forwarding applies to maildist, mailpatch and package commands only. FILES
~/.mailagent configuration file for mailagent. /usr/share/mailagent directory holding templates and samples. Spool/agenthelp help file Spool/distribs distribution list Spool/proglist comments for available distributions Spool/plsave records patchlevel of archived distributions Log/agentlog mailagent's log file BUGS
The proglist file ought to make a distinction between different versions of a same system. AUTHOR
Raphael Manfredi <Raphael_Manfredi@pobox.com> SEE ALSO
mailagent(1), package(1). ram MAILHELP(1)
All times are GMT -4. The time now is 05:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy