Sponsored Content
Top Forums Shell Programming and Scripting Perl - save results to output file. Post 302495532 by sureshcisco on Thursday 10th of February 2011 01:37:47 PM
Old 02-10-2011
Perl - save results to output file.

Can any one please help, the code works...I want the output of $result to be saved in an output.txt file which is lcoated in c:\\temp\\output.txt.


Code:
 
$filepath="C:\\temp\\ip.txt";
open (HOSTLIST,"$filepath"); 
@hosts=(<HOSTLIST>); 
 
foreach $host(@hosts) 
{ 
  $results = `nslookup $host`; 
  chomp ($host); 
  print ("Results for $host:\n"); 
  print ("$results\n\n");
} 
close (HOSTLIST);


Last edited by Scott; 02-10-2011 at 02:43 PM.. Reason: Quote tags -> Code tags
 

9 More Discussions You Might Find Interesting

1. Solaris

terminal output - save to file?

I have a window open on my ultra 10 - a terminal window connecting to a server. Is there any way I can log all output to this window to a log file on my ultra 10 ? (2 Replies)
Discussion started by: frustrated1
2 Replies

2. Shell Programming and Scripting

let curl output to stdout AND save to a file

hello hackers. i have a curl process running as cgi directly pushing stdout to the client. but i want to additionally save that stream to a file at the same time. any directions madly welcome. thanks in advance (3 Replies)
Discussion started by: scarfake
3 Replies

3. Shell Programming and Scripting

Save cURL verbose output to file or do it like browser "save as.."

hi there ! i have exactly the same problem like this guy here https://www.unix.com/shell-programming-scripting/127668-getting-curl-output-verbose-file.html i am not able to save the curl verbose output.. the sollution in this thread (redirecting stderr to a file) does not work for me.... (0 Replies)
Discussion started by: crabmeat
0 Replies

4. Shell Programming and Scripting

Way to save output result of a program into another new file...

Does anybody know any alternative way to save output result of a program into another new file? I got try the command below: program_used input_file > new_output_file program_used input_file >> new_output_file Unfortunately, both the ">" and ">>" is not work at this case to save the output... (6 Replies)
Discussion started by: patrick87
6 Replies

5. Shell Programming and Scripting

PERL Scripting: Diff 2 files and save output to file3

Hi, I need to create a script to compare 2 files and store the output in a 3rd file. This is how I do manually, but since I need to do this for about 150 files every week, I am trying to automate it using perl. diff -u file1 file2 > file3.patch For my script, - I have 2 files... (4 Replies)
Discussion started by: script2010
4 Replies

6. Shell Programming and Scripting

[Shell/Perl(?)] Prepending timestamps to console output & writing results to a file

I do a lot of TSM work and I embarked on what I thought would be an easy task, and I'd be very happy for any input to save the pounding my keyboard is receiving :] By default, the output of TSM's console has no timestamping, making it hard to sort through accurately. This puts my console into... (5 Replies)
Discussion started by: Vryali
5 Replies

7. Shell Programming and Scripting

Save output to file - inside a script ?

I'm using the following script to check cisco router health and I'd like to save output to a file, vty_runcmd.sh > /check/check-cisco-health script works and output is saved to a file. However using it in crontab file is created but output is not printed inside it. In crontab, */5 * * * *... (4 Replies)
Discussion started by: marmellata
4 Replies

8. Shell Programming and Scripting

Save output into file bash scripting

Hi there. i have created a program that in the end it will give output like this 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 .............. 17 i wonder how to save the output into a single string and into a file. i.e 1 10 11 12 9 2 3 8 13 14 7 4 5 6 15 17 (in this order,... (3 Replies)
Discussion started by: shdin271
3 Replies

9. Shell Programming and Scripting

Save value from output of Corestat and save in a list for each core

I am trying to modify the "corestat v1.1" code which is in Perl.The typical output of this code is below: Core Utilization CoreId %Usr %Sys %Total ------ ----- ----- ------ 5 4.91 0.01 4.92 6 0.06 ... (0 Replies)
Discussion started by: Zam_1234
0 Replies
OB_GET_FLUSH(3) 							 1							   OB_GET_FLUSH(3)

ob_get_flush - Flush the output buffer, return it as a string and turn off output buffering

SYNOPSIS
string ob_get_flush (void ) DESCRIPTION
ob_get_flush(3) flushes the output buffer, return it as a string and turns off output buffering. The output buffer must be started by ob_start(3) with PHP_OUTPUT_HANDLER_FLUSHABLE flag. Otherwise ob_get_flush(3) will not work. Note This function is similar to ob_end_flush(3), except that this function returns the buffer as a string. RETURN VALUES
Returns the output buffer or FALSE if no buffering is active. EXAMPLES
Example #1 ob_get_flush(3) example <?php //using output_buffering=On print_r(ob_list_handlers()); //save buffer in a file $buffer = ob_get_flush(); file_put_contents('buffer.txt', $buffer); print_r(ob_list_handlers()); ?> The above example will output: Array ( [0] => default output handler ) Array ( ) SEE ALSO
ob_end_clean(3), ob_end_flush(3), ob_list_handlers(3). PHP Documentation Group OB_GET_FLUSH(3)
All times are GMT -4. The time now is 04:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy