473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Threads, Need help

I 've got this script here and struggling to apply threads to the "ping" part of the program, Any help much appreciated.
Expand|Select|Wrap|Line Numbers
  1. use Net::Ping;
  2. use Getopt::Std;
  3.  
  4. sub usage
  5. {
  6. print "pingscan -f <Input file> -o <Output file>";
  7. exit 0;
  8. }
  9.  
  10. my %options;
  11. getopts('f:o:',\%options) || die usage();
  12.  
  13. usage() if!($options{'f'});
  14. usage() if!($options{'o'});
  15.  
  16. $p = Net::Ping->new("icmp");
  17.  
  18. if($options{'f'}){
  19. $ipfile = $options{'f'};
  20. }
  21.  
  22. if($options{'o'}){
  23. $opfile = $options{'o'};
  24. }
  25.  
  26. chomp($ipfile);
  27. open I,"<$ipfile" || die ("cannot open file");
  28. @host = <I>;
  29.  
  30. chomp($opfile);
  31.  
  32. open P,">>$opfile" || die ("cannot create output file");
  33.  
  34. foreach (@host){
  35. print P $_ if $p->ping($_, 2);
  36. }
Jul 15 '08 #1
1 1117
numberwhun
3,509 Expert Mod 2GB
Although I am experiencing some issues in adding the code tags to your posting, you really need to use them when adding code to your posts.

Regards,

Jeff
Jul 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: andrewpalumbo | last post by:
I'm trying to write some code which will split up a vector into two halves and run a method on the objects in the vector using two seperate threads. I was hoping to see a near linear speedup on an...
6
by: Simon Harvey | last post by:
Hi everyone, I need to make a service that monitors a directory for changes in the files contained within it. I have two questions: 1. I'm going to be using a FileSystemWatcher object to do...
6
by: m | last post by:
Hello, I have an application that processes thousands of files each day. The filenames and various related file information is retrieved, related filenames are associate and placed in a linked...
34
by: Kovan Akrei | last post by:
Hi, I would like to know how to reuse an object of a thread (if it is possible) in Csharp? I have the following program: using System; using System.Threading; using System.Collections; ...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
6
by: RahimAsif | last post by:
Hi guys, I would like some advice on thread programming using C#. I am writing an application that communicates with a panel over ethernet, collects data and writes it to a file. The way the...
7
by: Mark B | last post by:
Hi I was wondering if someone could help me with the syntax for some VB.Net ASPX code to: - Start 20 threads - End all threads after the sooner of 10 seconds or if all of the threads...
3
by: michdoh | last post by:
Hi All I'm looking for some help on creating a basic multi threaded application. i'n new to threads in this environment so for test purposes I've produced a very basic program. (which doesn't...
9
by: jdlists | last post by:
I have inheirted some existing code, that i will explain in a moment, have needed to extend and ultimately should be able to run in threads. I've done a bunch of work with python but very little...
9
by: koschwitz | last post by:
Hi, I hope you guys can help me make this simple application work. I'm trying to create a form displaying 3 circles, which independently change colors 3 times after a random time period has...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.