博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

ELM's Blog

工作、学习、生活、娱乐......
  wenzk.cublog.cn

关于作者
姓名:ELM
职业:网管[网吧管理员]
年龄:26
位置:辽宁 沈阳
介绍:一定要把网络管好
QQ:616621
Email:wzk<AT>wenzk<DOT>net
|| << >> ||
我的分类


一个通过ftp自动上载文件的Shell脚本[.netrc]
感觉不错,从来没有试过使用.nterc
#!/bin/bash
#
# iSight Auto Upload Script - by Dylan O'Donnell 2006
#####################################################
# Edit CAPITALS with appropriate details
# Notes : Change file path to a folder without other JPEGs
# : IF you get zero-byte files, try removing the "passive" line from the FTP stuff.
#
#####################################################

# Generate filename based on date stamp
date=$(date +%m%d%y%H%M%S).jpg;

# Take iSight Photo and store in /tmp with datestamp filename
/bin/isightcapture -w 640 -h 480 -t jpg /Users/USERACCOUNT/Documents/$date;

# Wait a little while, if Mac is waking from sleep, needs a moment to connect to network
sleep 60;

# Generate semaphore for connectivity by pinging NASA
isconnected=$(ping -c 1 www.nasa.gov | grep 64 | wc | awk '{print $1}');

# If connected...
if [ "$isconnected" -eq "1" ]; then

# Make .netrc FTP session commands on the fly
cat > ~/.netrc <<-EOF
machine WWW.YOURWEBSITE.COM
login USERNAME
password PASS
macdef init
lcd /Users/USERACCOUNT/Documents
cd REMOTE/DIR
passive
prompt
restrict
type binary
prompt
mput *.jpg
quit

EOF

# Run FTP session to put JPGs in webspace, then delete from /tmp
chmod 600 ~/.netrc
ftp -i WWW.YOURWEBSITE.COM
rm /Users/USERACCOUNT/Documents/*.jpg

else
# If not connected.. leave captures there until next time.
echo "No Connection, Image not transferred or deleted.";
fi


 原文地址 http://deography.com/record/bash.php
发表于: 2007-04-01,修改于: 2007-04-01 11:21,已浏览2586次,有评论0条 推荐 投诉


网友评论
 发表评论