summaryrefslogtreecommitdiff
path: root/examples/echo
diff options
context:
space:
mode:
authorArtyom Poptsov <poptsov.artyom@gmail.com>2014-01-22 11:51:23 +0400
committerArtyom Poptsov <poptsov.artyom@gmail.com>2014-01-22 11:51:23 +0400
commitbef37917fec368f488c18bd1a8c4869e916f96a7 (patch)
treea3cc4fcbc57a2a8337147355988023f91a2f8193 /examples/echo
parentexamples/echo/server.scm (main): Add `--port' option. Improve. (diff)
downloadguile-ssh-bef37917fec368f488c18bd1a8c4869e916f96a7.tar.gz
examples/echo/client.scm: Improve.
Diffstat (limited to 'examples/echo')
-rwxr-xr-xexamples/echo/client.scm47
1 files changed, 24 insertions, 23 deletions
diff --git a/examples/echo/client.scm b/examples/echo/client.scm
index 1ac1d36..5bd4468 100755
--- a/examples/echo/client.scm
+++ b/examples/echo/client.scm
@@ -45,9 +45,10 @@
(ssh auth)
(ssh key))
-(define *program-name* "echo-client")
-(define *default-identity-file*
- (string-append (getenv "HOME") "/.ssh/id_rsa"))
+(define *program-name* "client.scm")
+(define *default-identity-file* (format #f "~a/.ssh/id_rsa" (getenv "HOME")))
+(define *default-user* (getenv "USER"))
+(define *default-port* "22")
;; Command line options
@@ -60,19 +61,19 @@
(define (print-help)
"Print information about program usage."
- (display
- (string-append
- *program-name* " -- Echo client example.\n"
- "Copyright (C) Artyom Poptsov <poptsov.artyom@gmail.com>\n"
- "Licensed under GNU GPLv3+\n"
- "\n"
- "Usage: " *program-name* " [ -upi ] <host> <string>\n"
- "\n"
- "Options:\n"
- " --user=<user>, -u <user> User name\n"
- " --port=<port-number>, -p <port-number> Port number\n"
- " --identity-file=<file>, -i <file> Path to private key\n")))
+ (display (string-append "\
+" *program-name* " -- Echo client example.
+Copyright (C) Artyom V. Poptsov <poptsov.artyom@gmail.com>
+Licensed under GNU GPLv3+
+
+Usage: " *program-name* " [ options ] <host> <string>
+
+Options:
+ --user=<user>, -u <user> User name
+ --port=<port-number>, -p <port-number> Port number
+ --identity-file=<file>, -i <file> Path to private key
+")))
(define (handle-error session)
"Handle a SSH error."
@@ -111,13 +112,13 @@ errors."
(print-help)
(exit 0)))
- (let* ((options (getopt-long args *option-spec*))
- (user (option-ref options 'user (getenv "USER")))
- (port (string->number (option-ref options 'port "22")))
- (identity-file (option-ref options 'identity-file
- *default-identity-file*))
- (help-needed? (option-ref options 'help #f))
- (args (option-ref options '() #f)))
+ (let* ((options (getopt-long args *option-spec*))
+ (user (option-ref options 'user *default-user*))
+ (port (option-ref options 'port *default-port*))
+ (identity-file (option-ref options 'identity-file
+ *default-identity-file*))
+ (help-needed? (option-ref options 'help #f))
+ (args (option-ref options '() #f)))
(if help-needed?
(begin
@@ -133,7 +134,7 @@ errors."
(str (cadr args))
(session (make-session #:user user
#:host host
- #:port port
+ #:port (string->number port)
#:log-verbosity 0))) ;Be quiet
(connect! session)