![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need your Help on Unix Shell Scripting......... | vinayraj | UNIX for Advanced & Expert Users | 5 | 02-08-2008 03:00 AM |
| Unix Shell Scripting | premamadhuri | Shell Programming and Scripting | 4 | 11-04-2007 11:31 PM |
| Shell Scripting (Unix) | tt1ect | Shell Programming and Scripting | 3 | 04-15-2007 06:15 AM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 05:12 AM |
| Unix shell scripting | la_burton | UNIX for Dummies Questions & Answers | 6 | 10-22-2004 08:41 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Unix shell scripting
Hi,
we are writing this fields dynamically retrieved from database and writing into the file. $bmpRec = $bmpRec.'|'.$cust_id; # sp4 $bmpRec = $bmpRec.'|'.$serv_id; # sp5 $bmpRec = $bmpRec.'|'.$site_id; # sp6 $bmpRec = $bmpRec.'|'.$loc_id; # sp7 $bmpRec = $bmpRec.'|'.substr($si_room, 0, 25); # sp8 $bmpRec = $bmpRec.'|'.substr($floor, 0, 9); # sp9 $bmpRec = $bmpRec.'|'.substr($sof_id, 0, 20); # sp10 $bmpRec = $bmpRec.'|'.substr($cc_case_num, 0, 10); # sp11 $bmpRec = $bmpRec.'|'.substr($cc_part_num, 0, 30); # sp12 $bmpRec = $bmpRec.'|'. ""; # sp13, (cc_site_id) 01d removed from db $bmpRec = $bmpRec.'|'.substr($acc_type, 0, 20); # sp14 $bmpRec = $bmpRec.'|'.$speed_value; # sp15 $bmpRec = $bmpRec.'|'.substr($link_protocol, 0, 10); # sp16 $bmpRec = $bmpRec.'|'.$site_glbl_dlci; # sp17 $bmpRec = $bmpRec.'|'.$intnl_gw_popid; # sp18 $bmpRec = $bmpRec.'|'.substr($fr_encapsulation, 0, 10); # sp19 $bmpRec = $bmpRec.'|'.substr($csu_dsu, 0, 25); # sp20 $bmpRec = $bmpRec.'|'. ""; # sp21 (lpw) Finally we are printing the $bmpRec to a file printf OUT "$bmpRec|\n" When we are printing this variable into the file it has printed upto I # sp9 and also it has not printed the final new line character (\n) after this a shell script will append a trailer record (TRLR|727)with the total number of records in the file. Because the last record was half printed we are getting the trailer record on the same line (appended to the last record) as follows USP|200605|2212404|5314|15|880863|661897|CABL PLNT|1||TRLR|727| Last edited by Maruthi Kunnuru; 05-23-2006 at 03:12 AM. Reason: To give clear view of the problem |
| Forum Sponsor | ||
|
|
|
|||
|
I have seen ls, wc etc give false readings if the file is opened by another program which is writing to it.
if the output is not flushed then file size etc remains the same. try.... # cat flush.pl #!/usr/local/bin/perl open FH, ">flush.txt"; for (1..410) { print FH "abcdefg89\n"; } sleep 360; close FH; NOTE: The string is 10 chars (including \n), 410 lines written before sleep. therefore size should be 4100 bytes. The file is already open and not close yet on the sleep. # tail flush.txt abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdefg89 abcdef The block size of our system is 4096 so instead of 4100 bytes, 4096 is seen. The tail command will only show upto 4096 bytes. # ls -l flush.txt -rw-r--r-- 1 root system 4096 May 23 12:06 flush.txt Ls confirms only 4096 bytes is seen # wc -l flush.txt 409 flush.txt wc -l shows only 409 and note 410. The file will only show 4100 when you close the file. # ls -l flush.txt -rw-r--r-- 1 root system 4100 May 23 12:18 flush.txt |
|||
| Google The UNIX and Linux Forums |