免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: Steiny
打印 上一主题 下一主题

开贴发问:ftp脚本里面可以使用if判断语句么? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2009-05-07 11:43 |只看该作者
原帖由 我是DBA 于 2009-5-6 17:22 发表
版版的意思大致如下:
先用一个ftp写日志
然后通过脚本判断日志内容
进行第二次ftp传输



我知道大概思路了
先进行一次ftp,导出目录信息,然后if语句判断,不存在就执行带mkdir的ftp脚本,存在就执行不带mkdir的脚本?

这样,能实现效果,不过脚本显的繁琐了点哦

论坛徽章:
0
12 [报告]
发表于 2009-05-09 00:49 |只看该作者
本回复分两部分,第一部分是在两台Linux之间建立互信的过程,之后从客户机登录服务器不需要再键入密码.两台机器分别为:
服务器: RHEL5, 192.168.1.8, 用户为db2inst1
客户端: Fedora5, 192.168.1.10, 用户为wrl

第一部分完全为客户端Fedora5上的操作,拷屏如下,
$cd
$ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wrl/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wrl/.ssh/id_rsa.
Your public key has been saved in /home/wrl/.ssh/id_rsa.pub.
The key fingerprint is:
76:f8:39:0c:50:30:1c:2d:c3:8a:3a:68:74:39:5f:85 wrl@Venus
$ssh -l db2inst1 192.168.1.8 mkdir .ssh; chmod 0700 .ssh  
db2inst1@192.168.1.8's password:
$scp .ssh/id_rsa.pub db2inst1@192.168.1.8:.ssh/id_rsa.pub
db2inst1@192.168.1.8's password:
id_rsa.pub                                    100%  391     0.4KB/s   00:00   
$ssh -l db2inst1 192.168.1.8 touch .ssh/authorized_keys2; cat .ssh/id_rsa.pub >>.ssh/authorized_keys2
db2inst1@192.168.1.8's password:
$ssh -l db2inst1 192.168.1.8
Last login: Sat May  9 00:34:17 2009 from 192.168.1.10
$ /home/db2inst1>exit
$



第二部分建立一个名为rssh.sh的脚本文件并执行,结果如下,
$rssh.sh
192.168.1.8 has /tmp directory
192.168.8.8 doesn't have /tmpnotexist directory
$

rssh.sh的代码如下,
#!/bin/ksh

ssh -l db2inst1 192.168.1.8 [[ -d /tmp ]]
if [ $? -eq 0 ]; then
        echo "192.168.1.8 has /tmp directory"
else
        echo "192.168.8.8 doesn't have /tmp directory"
fi

ssh -l db2inst1 192.168.1.8 [[ -d /tmpnotexist ]]
if [ $? -eq 0 ]; then
        echo "192.168.1.8 has /tmpnotexist directory"
else
        echo "192.168.8.8 doesn't have /tmpnotexist directory"
fi

论坛徽章:
0
13 [报告]
发表于 2009-05-30 16:31 |只看该作者
不是太理解,学习中

论坛徽章:
0
14 [报告]
发表于 2009-05-30 17:48 |只看该作者
Steiny ,你的ftp 脚本是不是很有趣?能不能copy一份我看看呢?我想多学习下shell script
E-mail:linuxleio@gmail.com
谢谢~!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP