Thanks, to everyone who answered. I am still not sure what I am going to do. For now I am using this code below. However, I am going to try to do as
davidrw suggested, as this seems the simplest. I suppose I will have to be calling net start from within the script using backticks or system or something, but that doesn't seem like it should be a problem.
use strict;
use warnings;
use IPC::Open3;
#my $result = system("C:\\Programme\\Tor\\tor.exe &");
#print "sleeping";
#sleep(3);
my ($WR1, $RD1, $ER1);
my $tor_fhs = {};
my $pid = start_tor($tor_fhs);
sleep 1;
stop_tor($tor_fhs);
sub start_tor {
my $tor_fhs = shift;
open3( $tor_fhs->{wr}, $tor_fhs->{rd}, $tor_fhs->{err}, "C:\\Progr
+amme\\Tor\\tor.exe" );
print "tor started\n";
return $pid;
}
sub stop_tor {
my $tor_fhs = shift;
close($tor_fhs->{wr});
local($/) = undef;
close($tor_fhs->{rd});
#close($ER1);
print "tor stopped\n";
}
UPDATE: Ack, no, maybe that wasn't such a good idea. This starts the service, but doesn't stop it, so after a bit of playing around I had a bunch of processes that I had to stop using ctrl-alt-delete. Maybe time to stop monkeying with things I don't really understand and get this working using net start and net stop.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.