自学内容网 自学内容网

window批处理脚本:将本地的三个文件通过SCP传输到Linux设备上

文件名send_file.bat:

@echo off
setlocal

:: 提示用户输入远程IP地址
set /p remoteIpAddress=please input IP:

:: 定义本地文件名
set "localFile1=111"
set "localFile2=222"
set "localFile3=333"

:: 获取本地文件的完整路径
set "localFilePath1=%cd%\%localFile1%"
set "localFilePath2=%cd%\%localFile2%"
set "localFilePath3=%cd%\%localFile3%"

:: 检查文件是否存在
if not exist "%localFilePath1%" (
    echo File "%localFile1%" does not exist in the current directory.
    pause
    exit /b 1
)

if not exist "%localFilePath2%" (
    echo File "%localFile2%" does not exist in the current directory.
    pause
    exit /b 1
)

if not exist "%localFilePath3%" (
    echo File "%localFile3%" does not exist in the current directory.
    pause
    exit /b 1
)

:: 定义远程用户名和远程文件路径
set "remoteUsername=root"
set "remoteFilePath1=/usr/bin/"
set "remoteFilePath2=/usr/bin/"
set "remoteFilePath3=/usr/lib/"

:: 使用scp命令传输文件
scp "%localFilePath1%" %remoteUsername%@%remoteIpAddress%:%remoteFilePath1%
scp "%localFilePath2%" %remoteUsername%@%remoteIpAddress%:%remoteFilePath2%
scp "%localFilePath3%" %remoteUsername%@%remoteIpAddress%:%remoteFilePath3%

:: 等待5秒
timeout /t 5

endlocal

在window双击send_file.bat
在这里插入图片描述


原文地址:https://blog.csdn.net/weixin_37787043/article/details/142374939

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!