changing the output file for every script run 
Author Message
 changing the output file for every script run

I am running this script, however I would like it to change the output
file after every successful run. Is there a way to do this. I am
beating my brains as to how to accomplish this.

#!/usr/bin/perl -w
# file: ionex test
use Net::Telnet;
use constant HOST => '152.148.228.14';
use constant USER => 'admin';
use constant PASS => 'admin';
# loads the text file to be loaded via cli. populating the array
w/text config file
$telnet = Net::Telnet->new(HOST);
$telnet->open(HOST);
$telnet->waitfor('/[^Welcome]/');
$telnet->print ("\007");
$telnet->login(Name => USER,Password => PASS,Prompt => '/#/',Timeout
=> 30);















Tue, 01 Mar 2005 14:40:14 GMT  
 changing the output file for every script run

Quote:

>I am running this script, however I would like it to change the output
>file after every successful run. Is there a way to do this. I am
>beating my brains as to how to accomplish this.

Instead of this line:

Quote:
>open (LOGFILE,">>/usr/test.txt");

Add something like this instead:

(my $timestamp = localtime(time)) =~ tr/ /_/;
my $logfile = "/usr/${timestamp}_logfile.txt";
open LOGFILE,">$logfile" or die
   "Cannot open $logfile for writing:$!\n";

--
Regards, Helgi Briem
helgi AT decode DOT is



Tue, 01 Mar 2005 15:11:29 GMT  
 changing the output file for every script run

Quote:

> I am running this script, however I would like it to change the output
> file after every successful run. Is there a way to do this. I am
> beating my brains as to how to accomplish this.

if i understand what you want Y can try smth like this

$filename="log-".`/bin/date +%s`;
open(LOGFILE,"+>> $filename") or die "$!";

--
Regards,
Oleg Prokopyev
OAP4-RIPE
OAP1-UANIC



Tue, 01 Mar 2005 15:23:07 GMT  
 changing the output file for every script run

(snipped)

Quote:
> I am running this script, however I would like it to change the output
> file after every successful run. Is there a way to do this.

Do you want to change the contents of this output file
with each run or change the name of this output file
with each run?

You say "...after every...run." This indicates your
intent is to initiate another script which performs
an unknown task after another script exits.

Precisely, what is your goal?

Work towards developing an ability to write articles
which are clear, concise and coherent.

Purl Gurl



Tue, 01 Mar 2005 17:02:23 GMT  
 changing the output file for every script run
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Why not simply:

    print LOGFILE $telnet->print ("set page disable\n");

- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPYJY72PeouIeTNHoEQLenACeP/F7xmH458JQccZ1yY5cIAGPZ9wAnild
3hVpXSPBKU6MuBbgTI+qDGYX
=MN0z
-----END PGP SIGNATURE-----



Tue, 01 Mar 2005 22:30:05 GMT  
 changing the output file for every script run

Quote:



> >I am running this script, however I would like it to change the output
> >file after every successful run. Is there a way to do this. I am
> >beating my brains as to how to accomplish this.

> Instead of this line:
> >open (LOGFILE,">>/usr/test.txt");

> Add something like this instead:

> (my $timestamp = localtime(time)) =~ tr/ /_/;
> my $logfile = "/usr/${timestamp}_logfile.txt";
> open LOGFILE,">$logfile" or die
>    "Cannot open $logfile for writing:$!\n";

Thanks Helgi for your help. It works like a charm. I apologize to
those who could not understand my cryptic post. Sometimes it is
difficult to articulate what you are trying post when you have a
million things running through your head. Sorry again


Fri, 04 Mar 2005 22:18:19 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. In search of file searching script,output,every line occurance occurs

2. redirecting output from one perl script to a file (withough changing the perl script itself)

3. Perl script for changing page every day

4. Running Perl Scripts every day

5. run a script every few minutes

6. Incomplete output from crontab email: running shell scripts from a perl script

7. Passwd changes every 90 days

8. Running a CGI script without change the brower??

9. Getting parent process's environment variable to change when running a perl script

10. change configuration of image every 2 seconds?

11. Incremental HTML output as script is running

12. Run a new page from the output of cgi script

 

 
Powered by phpBB® Forum Software