如果/tmp下存在result开头的文本文件(如result_var_log.txt)则备份为result_var_log.bak(其他类似),如果不存在则直接将data的结果写入到该文件。 当前主要有两个疑问,一个是如何判断文件是否存在,另外判断是文本文件。
by djzhangxing - Linux新手园地 - 2014-05-25 18:04:52 阅读(1128) 回复(6)
[code] if [ -d "/home/logs/" ] then echo "yes"; else mkdir -p -m 777 "/home/logs/" fi [/code] 我想省去then echo "yes"; 这一部。 我想如果目录不存在,就新建个目录.
#!/bin/sh for x in `cat ipfile` do filedir=$(ssh -lroot 10.0.1.$x ls /etc/cron.d/Z*) if [ -f $filedir ]; then ssh -lroot 10.0.1.$x "(sed -e 's/^/#/g' $filedir > ./tmp&& \ cat ./tmp > $filedir)" fi done 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/17797/showart_104111.html
请教各位大虾: 问题:使用ssh Client(ssh Secure shell)无法正常使用Public_key登录 客户端软件 :ssh Secure shell 3.29 服务器端Linux: Fedora6 (sshd_config默认配置) 客户端使用软件生成2048 RSA 文件上传到服务器 .ssh/ 并改名为authorized_keys 使用客户端连接提示如下图错误: 以下为sshd_config文件内容:(基本为默认设置) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #Port 22 #P...
本帖最后由 prcardin 于 2014-03-05 16:40 编辑 shell判断本机能否ssh登陆批量远程服务器? 账号、密码:root/rootroot 这样的脚本怎么入手呢 比如脚本里对ip进行循环执行ssh命令时,到了输入密码这一步,立马退出,判断这台服务器是能够ssh登陆的,然后就这些服务器的ip写到一个文件里 # ssh -p22 192.168.6.56 -lroot Keyboard-interactive: PAM authentication Password: 需要输入密码时立即退出,将ip写到可以登陆的ip列...
[code]#!/bin/sh FILE_PATH=/u02/dbback/ebsdb cd $FILE_PATH[/code][quote] # sh archive_to_tape.sh : No such file or directory cd: /u02/dbback/ebsdb #. archive_to_tape.sh : No such file or directoryb [/quote] 路径确定是正确的。 类似写法在AIX上可以正常执行。求解,谢谢。
大家好,刚安装好FB的时候把root默认的shell更改为了 /usr/local/bi/bash(我使用ports安装了bash shell),昨天看到文章说最好不要更改root 默认shell,我就想改回去. # cshsh 编辑shell 到/bin/tcsh 当时由于不小心没有去掉/usr/,现在的shell 为/usr/bin/tcsh,当使用root登陆或su时,系统提士 /usr/bin/tcsh no such file or directory,重启到单用户 ,使用chsh 更改shell完毕,在vi编辑中:wq存盘退出时系统提示 chsh: entry inconsist...
shell文件存在的判断 shell数组 收藏 判断文件: WORKDIR=/home/tmp LOCAL_LIST_FILE=$WORKDIR/local.list #if no local.txt file, generate a new one if [ ! -f "$LOCAL_LIST_FILE" ]; then touch $LOCAL_LIST_FILE fi 注意:一定要有空格,判断文件是否存在,如果不存在,就生成一个新的 if [ ! -d /mnt ] # be sure the directory /mnt exists then mkdir...