Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/scp.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>1999-11-16 12:26:19 +0300
committerSimon Tatham <anakin@pobox.com>1999-11-16 12:26:19 +0300
commit1d837144c4446f5785393ade20998cad7ae4f046 (patch)
tree382bbe49497546eca42b0ab5b15d7e450761f387 /scp.c
parentcda91718503c7b264c9a24f6f79cac0862f6c74a (diff)
Update from Joris van Rantwijk: command line options to specify
port and password in scp [originally from svn r312]
Diffstat (limited to 'scp.c')
-rw-r--r--scp.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/scp.c b/scp.c
index d0f70ae5..1b9bcee0 100644
--- a/scp.c
+++ b/scp.c
@@ -1,6 +1,6 @@
/*
* scp.c - Scp (Secure Copy) client for PuTTY.
- * Joris van Rantwijk, Aug 1999.
+ * Joris van Rantwijk, Aug 1999, Nov 1999.
*
* This is mainly based on ssh-1.2.26/scp.c by Timo Rinne & Tatu Ylonen.
* They, in turn, used stuff from BSD rcp.
@@ -27,6 +27,8 @@ static int recursive = 0;
static int preserve = 0;
static int targetshouldbedirectory = 0;
static int statistics = 1;
+static int portnumber = 0;
+static char *password = NULL;
static int errs = 0;
static int connection_open = 0;
@@ -70,8 +72,14 @@ static void bump(char *fmt, ...)
void ssh_get_password(char *prompt, char *str, int maxlen)
{
HANDLE hin, hout;
- DWORD savemode;
- int i;
+ DWORD savemode, i;
+
+ if (password) {
+ strncpy(str, password, maxlen);
+ str[maxlen-1] = '\0';
+ password = NULL;
+ return;
+ }
hin = GetStdHandle(STD_INPUT_HANDLE);
hout = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -112,6 +120,9 @@ static void do_cmd(char *host, char *user, char *cmd)
cfg.port = 22;
}
+ if (portnumber)
+ cfg.port = portnumber;
+
/* Set username */
if (user != NULL && user[0] != '\0') {
strncpy(cfg.username, user, sizeof(cfg.username)-1);
@@ -727,9 +738,15 @@ static void usage()
{
printf("PuTTY Secure Copy client\n");
printf("%s\n", ver);
- printf("usage: scp [-p] [-q] [-r] [-v] [user@]host:source target\n");
- printf(" scp [-p] [-q] [-r] [-v] source [source..]"
- " [user@]host:target\n");
+ printf("Usage: scp [options] [user@]host:source target\n");
+ printf(" scp [options] source [source...] [user@]host:target\n");
+ printf("Options:\n");
+ printf(" -p preserve file attributes\n");
+ printf(" -q quiet, don't show statistics\n");
+ printf(" -r copy directories recursively\n");
+ printf(" -v show verbose messages\n");
+ printf(" -P port connect to specified port\n");
+ printf(" -pw passw login with specified password\n");
exit(1);
}
@@ -756,6 +773,10 @@ int main(int argc, char *argv[])
else if (strcmp(argv[i], "-h") == 0 ||
strcmp(argv[i], "-?") == 0)
usage();
+ else if (strcmp(argv[i], "-P") == 0 && i+1 < argc)
+ portnumber = atoi(argv[++i]);
+ else if (strcmp(argv[i], "-pw") == 0 && i+1 < argc)
+ password = argv[++i];
else if (strcmp(argv[i], "--") == 0)
{ i++; break; }
else