Concatenate Logs - Perl Question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Concatenate Logs - Perl Question
# 1  
Old 05-13-2009
Concatenate Logs - Perl Question

Hi All,

I am fresh to perl and had been using shell scripting in my past experiences.

In my part of perl program, i am trying to run a application command ccm stop, which should give some string output as the result. The output (error or sucess) has to be returned to an exisiting log file. Below is the piece of code

@cmstop = `ccm stop`;
open (LOGFILE, ">>$logfile");
print LOGFILE $cmstop;
close (LOGFILE);

But the output is not captured in the logfile. Any help/clue is highly appreciated
# 2  
Old 05-13-2009
because you are using $cmstop. check how you declared the variable cmstop.
# 3  
Old 05-13-2009
Thanks for ur reply.. I tried correcting @cmstop as well.. it doesn't work

@cmstop = `ccm stop`;
open (LOGFILE, ">>$logfile");
print LOGFILE @cmstop;
close (LOGFILE);

The actual ccm stop command returns the below answers

C:\Documents and Settings\use>ccm status
Sessions for user abcd:

No sessions found.

Current project could not be identified.

And i am expecting the output in the $logfile too.
# 4  
Old 05-13-2009
have you defined $logfile?
# 5  
Old 05-13-2009
what are the contents of the logfile after this command ??

BTW you are reading input in array and print a variable ???

try
Code:
chomp ( $cmstop = `ccm stop` ) ; 
open (LOGFILE, ">>$logfile");
print LOGFILE $cmstop;
close (LOGFILE);

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If I ran perl script again,old logs should move with today date and new logs should generate.

Appreciate help for the below issue. Im using below code.....I dont want to attach the logs when I ran the perl twice...I just want to take backup with today date and generate new logs...What I need to do for the below scirpt.............. 1)if logs exist it should move the logs with extention... (1 Reply)
Discussion started by: Sanjeev G
1 Replies

2. Shell Programming and Scripting

Question /help understanding vi logs ?

Experts, I have a question. Where are the vi logs are being stored. For example: any command used within vi editor using :! ,(ex: :! pwd ex: :! ls -l ), so where the vi writes the command logs , dont see in .sh_history file so wondering. Shell: /usr/bin/ksh Thanks, (7 Replies)
Discussion started by: rveri
7 Replies

3. UNIX for Dummies Questions & Answers

perl filter unique and concatenate

Hi experts, I have some input like below, TEST A function W TEST A function X TEST B function Y TEST C function Z TEST C function ZY i would like to have below output, TEST A function W&X TEST B function Y TEST C function Z&ZY Please kindly help on this, i am cracking my head... (2 Replies)
Discussion started by: mingfatty
2 Replies

4. Shell Programming and Scripting

How to concatenate texts in perl only?

Hi, I want to concatenate the texts in the file but there are different scenario's. Ist Scenario. The contents of file has id`language,sequence number,text,language Here id`language is a key pair to identify the correct language. Sequnce number is the order the text being inserted. Text... (3 Replies)
Discussion started by: vanitham
3 Replies

5. Shell Programming and Scripting

Perl concatenate an array

Not a perl guru and need some help with a script I inherited. My perl script has a variable that is concatenated and works fine as is, but what I need is to remove a string in the output and input a files content. This is emailed as a html report and I can't get the file to output in the email... (5 Replies)
Discussion started by: numele
5 Replies

6. Shell Programming and Scripting

Rotating logs in Perl without message loss

(I'm aware log rotation is a common subject, but I tried searching and couldn't find an answer) For some time now, I've been using the Logfile::Rotate module to rotate logs in a log-monitoring script. So far, I haven't experienced any problems, and it works great because I can use it in Linux... (1 Reply)
Discussion started by: w1r3d
1 Replies

7. UNIX for Dummies Questions & Answers

Perl Scripting for monitoring logs

Hi, I am new to perl. I want to write a perl script to monitor logs. Where i want to monitor exceptions logged or any kind of error strings. I have a dir(On Solaris) with multiple log file which keeps rolling to .gz file after some time in that same dir. These logs files size keeps on... (1 Reply)
Discussion started by: solitare123
1 Replies

8. Shell Programming and Scripting

Perl script to rotate logs

I have a shell script that will gzip/tar/archive application logs that are over 20 days old which works just fine, but I would like to convert to a Perl script. Problem is, I'm a beginner with Perl and all attempts so far have failed. Basicaly I have a log dir /app/logs that contains several... (18 Replies)
Discussion started by: theninja
18 Replies
Login or Register to Ask a Question