Perl - update output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl - update output
# 1  
Old 01-20-2010
Perl - update output

I need help with the following code. It does what i want it to, but since I clear the screen and do not update it when i finally ^C my scroll back buffer is filled with garbage. Term::Cap might not be the best way to go, i am trying to keep this to Core Modules due to the difficulties of getting things approved to be installed at work, but if not possible i am open to other modules.

Is there anyway i can just update the screen in place. Also the @host_array will be read from a file so the number of hosts can vary from day to day. Any help would be appreciated or point me in the right direction and i can figure it out.

Thanks,

Sean

Code:
#!/usr/bin/perl

use Net::Ping;
use Term::Cap;

@host_array = qw(slag sludge snarl swoop);

$terminal = Term::Cap->Tgetent( { OSPEED => 9600 } );
$clear_string = $terminal->Tputs('cl');

while(1) {
  print $clear_string;
  # High precision syntax (requires Time::HiRes)
  foreach $host (@host_array)
    {
    $p = Net::Ping->new();
    $p->hires();
    ($ret, $duration, $ip) = $p->ping($host, 5.5);
    printf("$host [ip: $ip] is down\n") unless $p->ping($host, 2);
    printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n", 1000 * $duration)
    if $ret;
    $p->close();
  }
  sleep 2;
}

# 2  
Old 01-21-2010
Rather than messing with Termcaps, can you just invoke a standard "clear" command?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need solution to compare two file and update and append the output

Hi All, I have two files File1 frame,007C1 server1_Parent frame,007C3 server2_Silver frame,007EE server3_Bronze frame,00855 server4_Parent frame,00856 server4_Parent frame,00858 server5_Parent frame,008FA server6_Silver frame,008FB server6_Silver frame,008FC server6_Silver... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

2. Shell Programming and Scripting

Update perl code with parser

The below perl code imports the data in the attached document. However, I can not seem to update the perl code to include a parser like in the desired tab of that document. Thank you :). Most of the data for the parse is included in the document except for the gene and RNA which can is... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

How to write a update query in perl script?

can any one suggest me on how to write a update query in perl script for Oracle database and also tell me abt how we can write a code for sending mails with report as attachment to appropriate persons? (1 Reply)
Discussion started by: Ramesh V Kumar
1 Replies

4. Shell Programming and Scripting

Perl help - how to assign output of perl to variable

Hi, guys, i have a script i inherited from a coworker but i'm not perl savy. The script works but i would like it to work better. I want to run this command ./ciscomgrtest.pl -r "show version" -h hosts.router and have the script goto each router in the hosts.router file and run the command... (2 Replies)
Discussion started by: whipuras
2 Replies

5. UNIX for Advanced & Expert Users

perl and HP-UX : instmodsh in combination with software depot : update inventory for installed Perl

we create a HP-UX software depot with a new perl-modul. after installation of the software depot, the perl module i can't find with instmodsh in the inventory for installed Perl modules. - i have learned of using instmodsh command : i find out what modules are already installed on my system. ... (0 Replies)
Discussion started by: bora99
0 Replies

6. Shell Programming and Scripting

perl script to update a xml file

Hi experts, I have a set of xml files in folder which has the below field. <mm:sessionID>157.235.206.12900397BE4:A</mm:sessionID>, I need to update this field regularly with new session id, which I have it from a login file. Can anyone tell me how to add a new value in <mm:sessionID>... (3 Replies)
Discussion started by: amvarma77
3 Replies

7. Shell Programming and Scripting

using Perl with rrdtool to create and update graphs

Hi guys, im having real difficulty getting my head around perl and rrdtool and was hoping someone could help I want to run a perl script from cron which retrieves the data every 5 mins, creates .rrd's if not already created, and updates the DS from the reultsHash or $key, then creates the... (2 Replies)
Discussion started by: jeffersno1
2 Replies

8. Shell Programming and Scripting

Perl: update lastmod in xml file

I'm trying to write a perl script that I can run as a cron job in root of my web server that will look for .shtml files get their last modified date and replace it in the sitemap_test.xml file. the problem is the substitution doesn't work and when I print to MYFILE it adds the lastmod to the end of... (3 Replies)
Discussion started by: skilodge
3 Replies

9. Linux

perl update while script is loaded

Hi All, What will happen to the perl script loaded on the memory if I do perl update? Thanks. (1 Reply)
Discussion started by: itik
1 Replies

10. Linux

perl update RHSA-2008:0522

Hi All, I can't find from RHN the complete instructions with this perl update. Does it need reboot after the update? Thanks in advance. (1 Reply)
Discussion started by: itik
1 Replies
Login or Register to Ask a Question