My Server machine run Window,and it installed Cygwin.
My Client machine run linux.
In Clinent machine.I do this:
[sikaiwei@login-1-2 v1.4]$ bash test.sh CHUN~19900405 [email protected]:/ifs2/BC_MG/GROUP/sikaiwei/ssh/v1.4
start
PuTTY Secure Copy client
Release 0.63
Usage: pscp [options] [user@]host:source target
pscp [options] source [source...] [user@]host:target
pscp [options] -ls [user@]host:filespec
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-p preserve file attributes
-q quiet, don't show statistics
-r copy directories recursively
-v show verbose messages
-load sessname Load settings from saved session
-P port connect to specified port
-l user connect with specified username
-pw passw login with specified password
-1 -2 force use of particular SSH protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-noagent disable use of Pageant
-agent enable use of Pageant
-batch disable all interactive prompts
-unsafe allow server-side wildcards (DANGEROUS)
-sftp force use of SFTP protocol
-scp force use of SCP protocol
end
It seems warn me that I use 'pscp' in my test.sh file worngly! But I don't.
And my test.sh is:
#!/bin/bash
sshpass -p 'CHUN~19900405' ssh [email protected] '
echo start;
touch final_result.txt;
pscp -pw $1 final_result.txt $2;
echo end;
';
But when I use ".." instead of '..',like
#!/bin/bash
sshpass -p 'CHUN~19900405' ssh [email protected] "
echo start;
touch final_result.txt;
pscp -pw $1 final_result.txt $2;
echo end;
";
It don't repost error :
[sikaiwei@login-1-2 v1.4]$ bash test.sh CHUN~19900405 [email protected]:/ifs2/BC_MG/GROUP/sikaiwei/ssh/v1.4
start
end
I must use '..' instead of ".." to use enviorment variable of Server machine.like
[sikaiwei@login-1-2 v1.4]$ sshpass -p 'CHUN~19900405' ssh 172.16.22.53 -l sikaiwei "getId=$ORANGE;echo $ORANGE;ORANGE=$((ORANGE+1));echo $ORANGE;echo 'getId is '+$getId;"
The $ORANGE is variable of Server machine.
So I must use '..',and how to still use $1,$2 to get arguements ?