Printing a message in file without opening it in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Printing a message in file without opening it in perl
# 1  
Old 03-12-2012
Printing a message in file without opening it in perl

Hello friends,

i have a perl script as below ...

Code:
for (0 ..$#values)
{

##want to print some message here in Report.txt file

print `find /abc/xyz/pqr/$values[$a]" -type f -ls` >> Report.txt

}


I am able to get output of
Code:
print `find /abc/xyz/pqr/$values[$a]" -type f -ls` >> Report.txt

in Report.txt file.

but print "message " >> Report.txt is not working....

Can anyone help me....

Last edited by pludi; 03-12-2012 at 12:55 PM..
# 2  
Old 03-12-2012
1. What is the exact requirement?
2. You could use File::Find module of perl if you want to traverse through a directory structure.
This User Gave Thanks to balajesuri For This Post:
# 3  
Old 03-12-2012
Thanks for your time friend.
Here are the answers for your question:-
1. Exact requirement is that i am listing output(how many files are there with timestamp) of specified directories in a file(Report.txt).
But before printing output for every directory in loop i want to print a Message in Report.txt file that this output is for this "specified directory"....
2. I will also try with that.... Smilie ...

---------- Post updated at 09:43 PM ---------- Previous update was at 09:43 PM ----------

Thanks for your time friend.
Here are the answers for your question:-
1. Exact requirement is that i am listing output(how many files are there with timestamp) of specified directories in a file(Report.txt).
But before printing output for every directory in loop i want to print a Message in Report.txt file that this output is for this "specified directory"....
2. I will also try with that.... Smilie ...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Opening a file in perl

Hi I need to open a file if a condition(for example a if a regular expression) is met. How do i do this ? open (file) if (some regex)..... (3 Replies)
Discussion started by: manutd
3 Replies

2. Shell Programming and Scripting

Perl, searching multiple files and printing returned line to new file

I am trying to find a way to utilise the full potential of my cpu cores and memory on my windows machine. Now, I am quite familiar with grep, however, running a Unix based OS is not an option right now. Unfortunately, the 32 bit grep for windows that I am running, I cannot run multiple... (1 Reply)
Discussion started by: Moloch
1 Replies

3. Shell Programming and Scripting

Opening File names with spaces inside it !- PERL

I developed a perl code..And the excerpt from it is given below... open(HANDLE,$cmp_path) ; #reading the xml file from the file path while($file_path = <HANDLE>) I have list of XML files to read from a folder. It has some spaces inside the name of the file...I used "\"... (2 Replies)
Discussion started by: gameboy87
2 Replies

4. Shell Programming and Scripting

Perl-opening a file then copying files

Good morning guys!! Im still practicing with Perl and now Im trying to open a file, and copy its contents to another file. Them I want to remeove the information out of the orginal file after it is copied over. The flow should be messages-->messages1-->messages2. Kind of like a log... (1 Reply)
Discussion started by: bigben1220
1 Replies

5. Shell Programming and Scripting

shell script, why isn't if printing message?

Why isn't printing message? 1 #!/bin/sh 2 3 something(){ 4 echo "Inside something" 5 echo $1 $2 6 } 7 val=$(something "Hello " "world") But it prints. 1 #!/bin/sh 2 3 something(){ 4 echo "Inside something" 5 echo $1 $2 6 } 7... (4 Replies)
Discussion started by: cola
4 Replies

6. Programming

A question about printing error message with perror

Dear all, I use perror in order to print an error message to the standar error. For example if a C program is called without its two necessary command line parameters then : if (argc != 3) { perror("use: ./myProgram <source file> <target file>\n"); return 1; } Now the... (2 Replies)
Discussion started by: dariyoosh
2 Replies

7. Shell Programming and Scripting

perl/mail - inserting file text in message body

I've got the following code sub mail_report { $Mailer = '/usr/sbin/sendmail joe@somewhere.net'; open MAIL,"|$Mailer"; print MAIL "Subject: $X connection attempt \n"; open MESSAGE, "<$outdir$X"; print MESSAGE '$outdir$X\n'; close MESSAGE; close MAIL; } #End... (2 Replies)
Discussion started by: thumper
2 Replies

8. Shell Programming and Scripting

printing an empty line in a file (perl)

I know this must be really easy, but i can't get it to work I've got a perl script, with a file. I want to print an empty line, and the following doesn't seem to work: print nameoffile "\n" thanks for your help!! (3 Replies)
Discussion started by: kfad
3 Replies

9. Shell Programming and Scripting

Opening Perl

I have gone to /usr/bin/ and click on perl but notting happens.also notting happens when i click on c/c++ or any other program whats wrong ? (2 Replies)
Discussion started by: perleo
2 Replies
Login or Register to Ask a Question