Updating a CSV file by multiple PERL scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Updating a CSV file by multiple PERL scripts
# 1  
Old 02-17-2010
Error Updating a CSV file by multiple PERL scripts

Hi Friends,

I'm writing code to update a CSV file by multiple PERL scripts.
I've around 2000 PERL scripts which need to register their entries into a CSV file. Hence, I'm inserting following line code in all the 2000 PERL scripts.

Code:
open(FILE, ">>/software/app/TASKS/Batch_Job_Log_$rundate.csv");
sleep(60);
printf (FILE "$JobName\_$JobNumber, $rundate\n");
close(FILE);

Problem is, only around 500 jobs are making their entries in the above CSV file out of 2000. But as shown above I'm giving some delay [sleep (60)] to handle CSV file by multiple PERL scripts.

Could any of you help me to improve the above scenario (updating CSV for all 2000 PERL scripts)?

Thanks and Regards / Lokesha R.

Last edited by Franklin52; 02-17-2010 at 05:56 AM.. Reason: Please use code tags!
# 2  
Old 02-18-2010
I think 'sleep (60);' is to allow other perl scripts to write the same file, which is already opened by some other script. That should work fine, I believe.
# 3  
Old 02-18-2010
Thanks for your reply, Ganapati.

I thought so, but I don't know whether this is the right approach to allow multiple scripts to write the same CSV file.
# 4  
Old 02-18-2010
Hi.

Have you considered the advice in:
Code:
perldoc -q lock

cheers, drl
# 5  
Old 02-19-2010
Thanks for the reply drl.

But I donot want to lock the CSV file, it should be open for all the scripts to update their data? Please correct me, if I'm understanding your intention wrongly.

With Thanks and Regards / Lokesha R.
# 6  
Old 02-19-2010
Hi.

I was thinking of locking, then unlocking a file in the sense of avoiding simultaneous access to the file, which could result in over-writing changes, as described in File locking - Wikipedia, the free encyclopedia ... cheers, drl
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

2. Shell Programming and Scripting

Log file is not updating when I run shell scripts scheduled thru crontab

Hi Forum, Good Day! I have created an empty html file wtih permissoin 777 created shell script(with permission 777) , code is below. #=======================start============== . /data09/oracle/apps_st/appl/D_oraapp095.env rm -rf /home/mnp/Test_log.txt echo... (1 Reply)
Discussion started by: kartheekbk
1 Replies

3. Shell Programming and Scripting

How to create a variable without multiple concats in a perl scripts that makes a bsub?

The red text at the bottom represents the three lines I want to address. I'm dynamically creating a bsub with a perl script and would like to create the fasta_16S variable in a single line....not three. I'm having difficulty in getting the syntax correct. Obviously, there is some confusion... (3 Replies)
Discussion started by: jdilts
3 Replies

4. Shell Programming and Scripting

Split a .csv File into Multiple Files

Hi guys, I have a requirement where i need to split a .csv file into multiple files. Say for example i have data.csv file and i have splitted that into multiple files based on some conditions i.e first file should have 100, last file 50 and other files 1000 each. Am passing the values in... (2 Replies)
Discussion started by: azherkn3
2 Replies

5. Shell Programming and Scripting

Script for updating a .csv file

Hello guys, I have one .csv file with all the file names(.c,.h,.sm,.txt etc)..... Now i have compared two baseline in UCM and got a report in .txt file,which looks like this...... DIFFBL INT_1029_Rel6.0.0.90@\DIR_PVOB STD_6.0.0.50_UCM@\DIR_PVOB (COMPONENT TEXT) Comparing the following: ... (14 Replies)
Discussion started by: suvenduperl
14 Replies

6. Shell Programming and Scripting

Updating a line in a large csv file, with sed/awk?

I have an extremely large csv file that I need to search the second field, and upon matches update the last field... I can pull the line with awk.. but apparently you cant use awk to directly update the file? So im curious if I can use sed to do this... The good news is the field I want to... (5 Replies)
Discussion started by: trey85stang
5 Replies

7. Shell Programming and Scripting

Running many PERL scripts in one file

Hi, I have many PERL scripts in my system(Solaris 10 UNIX OS).I want to define all scripts in one file and run.Please suggest how to define. (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

8. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

9. UNIX for Advanced & Expert Users

Creating multiple worksheets in CSV file

Hello, I've been tasked with sending 3 types of data (file size, row count, and file name) to a csv file every month for various vendors. I have been asked to put this in one csv or xls file with each vendor being a different tab (or worksheet). Until now, we have been finding and emailing... (4 Replies)
Discussion started by: tekster757
4 Replies

10. UNIX for Advanced & Expert Users

Updating a csv file held on a unix box with excel running on windows

Hi, my question is quite simple: Can I update a csv file which is held on a unix box (and which a script on the same box uses) with Microsoft Excel running in a windows environment? Or, is there a free spreadsheet package available to run in unix that will update my csv file. I know it's easy to... (5 Replies)
Discussion started by: Sn33R
5 Replies
Login or Register to Ask a Question