Exemplo n.º 1
0
        public static (int, string) UploadFileToRemote(string host, string username, string password, string srcFile, string destFile)
        {
            int    errCode = 0;
            string result  = "";
            string cmd     = $"sshpass -p {password} scp -o StrictHostKeyChecking=no  -o LogLevel=ERROR {srcFile} {username}@{host}:{destFile}";

            Log.Information($"CMD: {cmd}");
            (errCode, result) = BashUtils.Bash(cmd, wait: true, handleRes: true);
            return(errCode, result);
        }
Exemplo n.º 2
0
        protected void RetriableUploadFile(string host, string srcPath, string dstPath)
        {
            int    code, retry = 5;
            string error;

            for (var i = 0; i < retry; i++)
            {
                (code, error) = BashUtils.UploadFileToRemote(host, _username, _password, srcPath, dstPath);
                if (code == 0)
                {
                    break;
                }
                else
                {
                    Log.Error($"will retry to upload file from {srcPath} to {dstPath} for {error}");
                }
            }
        }