tags 513571 + patch
thanks
* Gerfried Fuchs <[email protected]> [2009-01-30 11:23:48 CET]:
> When using ctel to test e.g. some mail servers for consistency, it's
> quite inconvenient to have to put :25 after every single host. It would
> be quite helpful if it's possible to be able to specify a different
> default port through a -p switch.
I have quickly hacked together a patch for this thing, it should be
quite straight-forward:
#v+
$> diff -ub /usr/bin/ctel.orig /usr/bin/ctel
--- /usr/bin/ctel.orig 2008-10-01 06:22:34.000000000 +0200
+++ /usr/bin/ctel 2009-01-30 11:53:15.000000000 +0100
@@ -86,7 +86,7 @@
my $scriptname = $0;
$scriptname =~ s!.*/!!; # get the script name, minus the path
-my $options = 'dDv?hHuqQgGist:T:c:l:o:e:'; # Command line options list
+my $options = 'dDv?hHuqQgGist:T:c:l:o:e:p:'; # Command line options list
my %options;
my %config;
my $debug = 0;
@@ -778,6 +778,7 @@
sub setup_helper_script() {
logmsg( 2, "Setting up helper script" );
+ my $defaultport = (defined $options{p}) ? $options{p} : "";
$helper_script = <<" HERE";
my \$pipe=shift;
my \$svr=shift;
@@ -801,17 +802,13 @@
\$command .= \$user;
}
}
- if(\$port) {
if("$config{comms}" eq "telnet") {
- \$port = \$port ? "\$port" : "";
+ \$port = \$port ? "\$port" : "$defaultport";
\$command .= "\$svr \$port";
} else {
- \$port = \$port ? "-p \$port" : "";
+ \$port = \$port ? "-p \$port" : "$defaultport";
\$command .= "\$port \$svr";
}
- } else {
- \$command .= "\$svr";
- }
\$command .= " || sleep 5";
# warn("Running:\$command\\n"); # for debug purposes
exec(\$command);
#v-
I wasn't even sure why the helper_script should check for a handed over
port when in the contained block $port will be checked explicitly for
being defined anyway. ;) Given the way exec is called in the end it
doesn't matter for multiple whitespace in between, but personally I
would suggest to try an approach of handing over an array to exec()
instead of a string, to avoid possible pitfalls. I just went this
approach to make the diff as small as possible. :)
So long, and thanks!
Rhonda
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]