检查文件是否存在于远程服务器上
来源:互联网 发布:外文数据库免费入口 编辑:程序博客网 时间:2024/06/05 18:51
检查文件是否存在于远程服务器上
本文描述的方法是使用 ssh 访问远程主机。首先需要启用无密码的 ssh 登录到远程主机, 这样您的脚本可以在非交互式的批处理模式访问远程主机。您还需要确保 ssh 登录文件有读权限。
使用bash判断文件是否存在于远程服务器上
#!/bin/bash ssh_host="owen@remote_machine" file="/data/log/my_test.txt" if ssh $ssh_host test -e $file; then echo $file exists else echo $file does not exist fi
使用python判断文件是否存在于远程服务器上
#!/usr/bin/python import pipes import subprocess ssh_host = 'owen@remote_machine' file = '/data/log/my_test.txt' resp = subprocess.call( ['ssh', ssh_host, 'test -e ' + pipes.quote(file)] ) if( 0 == resp ): print ('{} exists'.format( file ) ) else: print ('{} does not exist'.format( file ) )
使用perl判断文件是否存在于远程服务器上
#!/usr/bin/perl my $ssh_host = "owen@remote_machine"; my $file = "/data/log/my_test.txt"; system "ssh", $ssh_host, "test", "-e", $file; my $rc = $? >> 8; if ($rc) { print "$file does not exist\n"; } else { print "$file exists\n"; }
阅读全文
1 0
- 检查文件是否存在于远程服务器上
- 检查文件是否存在于远程服务器上
- C# 检查网络是否连通,判断远程文件是否存在
- 检查文件是否存在
- PathFileExists检查文件是否存在
- QT检查文件是否存在
- Delphi 检查文件是否存在
- ajax判断远程服务器是否存在某文件
- 判断远程网络上的文件是否存在
- 判断远程文件是否存在。、
- 判断远程文件是否存在
- 判断远程文件是否存在
- 判断远程文件是否 存在
- java服务器检查url是否存在
- 判断文件在ftp服务器上是否存在
- ios 文件操作 检查文件是否存在
- mongoose — 检查ObjectId 是否存在于数组中
- 用JavaScript检查文件是否存在
- OpenCV3.3-Python3.6.2中KNN使用举例
- JDesktopPane改变窗体大小时背景图片自动适应窗体大小
- Redhat Linux 7.3网络服务无法启动解决办法
- checkbox js验证只有一个可选
- RNG类
- 检查文件是否存在于远程服务器上
- Tensorflow-Mask RCNN
- 常用开发工具介绍
- iOS开发实现HTTPS之 cer 文件的使用
- Windows上使用SecureCRT软件连接Linux终端 — 解决问题;The remote system refused the connection
- 十万个为什么
- C语言中用队列和搜索解决"加1乘2平方问题"
- 赋值中类型的转换
- 历史版本的firefox下载