]> git.nbdom.net Git - nb.git/commitdiff
Option ssh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 1 Mar 2016 17:24:15 +0000 (17:24 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 1 Mar 2016 17:24:15 +0000 (17:24 +0000)
bin/dbq

diff --git a/bin/dbq b/bin/dbq
index 7d7409a63eec16a4475b2603fe024a0ee3b9d1b9..a2ebcc45d54236226a99a3f3ea4c6544cb4c868b 100755 (executable)
--- a/bin/dbq
+++ b/bin/dbq
@@ -54,6 +54,7 @@ my $CURL_OPT_EXP = join('|',map{ /^(.*?)\|/ ? $1 : $_ } @CURL_OPT);
 my $VERBOSE = $main::VERBOSE = 0;
 my $DEBUG = $main::DEBUG = 0;
 
+exec('ssh',$ARGV[0] && shift @ARGV,$NAME,@ARGV) if @ARGV and $ARGV[0] eq '--ssh' and shift @ARGV;
 csv2txt("\t",shift @ARGV) if @ARGV and $ARGV[0] eq '--csv2txt' and shift @ARGV;
 curl_help() if @ARGV and $ARGV[0] eq '--curl_help' and shift @ARGV;
 parse_debug() if @ARGV and $ARGV[0] eq '--parse_debug' and shift @ARGV;
@@ -152,7 +153,7 @@ if ($keys{format} eq 'nc') {
 #################################################################################
 
 # Push key=value
-push(@cmd,map {('--data-binary',esc($_).'='.esc($keys{$_}))} sort keys %keys);
+push(@cmd,map {('--data-binary',uri_esc($_).'='.uri_esc($keys{$_}))} sort keys %keys);
 
 warn "$NAME: Command: ",join(" ",map{/\s+/ ? '"'.$_.'"' : $_} @cmd),"\n" if $VERBOSE;
 system @cmd;
@@ -243,7 +244,7 @@ sub csv2txt {
   exit;
 }
 
-sub esc {
+sub uri_esc {
   return URI::Escape::uri_escape($_[0]);
        local $_=shift;s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
        return $_;
@@ -392,6 +393,7 @@ Curl wrapper
 
 =head1 OPTIONS
 
+ option[ssh=s]      SERVER Run the script on that server
  option[verbose|v+] Verbose mode: increase the verbosity level.
  option[debug+]     Debug mode: increase the verbosity level.
  option[version|V]  Print version (default: $VERSION)