免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1589 | 回复: 8
打印 上一主题 下一主题

一段shell 几点疑问的地方 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-24 16:43 |只看该作者 |倒序浏览
----------------------------------------------------------------------------------------
echo "取得sp回执"
ftp -niv $1 <<EOF   
user $2 $3
bin
prompt
lcd $4/down
cd /opt/cj1/ftp/sp/070/down
mget SP*.res
###mdelete SP*.res
bye
EOF
echo "***********"

--------------------------------------------

1,这里的ftp -niv $1 <<EOF   -niv $1<<EOF是什么意思?    与重定向>>这个有什么不同?
2 user $2 $3 是先前定义的变量吗???是指代用户名 还是代表用户名和密码

3  lcd 是强制转换目录到ftp上去的目录 这里的$4是什么
4  最后又出现了大写的EOF  这个EOF到底是什么?

论坛徽章:
1
处女座
日期:2014-12-23 17:59:27
2 [报告]
发表于 2009-03-24 16:53 |只看该作者
原帖由 lijie5 于 2009-3-24 16:43 发表
----------------------------------------------------------------------------------------
echo "取得sp回执"
ftp -niv $1  

呵呵, lz 问题还真多.
<< 是Here Doc.
$1...$n是参数.

论坛徽章:
0
3 [报告]
发表于 2009-03-24 16:56 |只看该作者
原帖由 leetaedong 于 2009-3-24 16:53 发表

呵呵, lz 问题还真多.

here doc 是什么  $1 和$2是参数的话 该参数在哪个地方可以看到?

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
4 [报告]
发表于 2009-03-24 16:58 |只看该作者
1.4

  1.    Here Documents
  2.        This type of redirection instructs the shell to read  input  from  the
  3.        current  source  until  a  line containing only word (with no trailing
  4.        blanks) is seen.  All of the lines read up to that point are then used
  5.        as the standard input for a command.

  6.        The format of here-documents is:

  7.               <<[-]word
  8.                       here-document
  9.               delimiter
复制代码


2.3

  1.    Positional Parameters
  2.        A  positional  parameter is a parameter denoted by one or more digits,
  3.        other than the single digit 0.   Positional  parameters  are  assigned
  4.        from  the  shell's arguments when it is invoked, and may be reassigned
  5.        using the set builtin  command.   Positional  parameters  may  not  be
  6.        assigned to with assignment statements.  The positional parameters are
  7.        temporarily replaced when a shell function is executed (see  FUNCTIONS
  8.        below).

  9.        When  a positional parameter consisting of more than a single digit is
  10.        expanded, it must be enclosed in braces (see EXPANSION below).
复制代码


有时间读新手导航吧

论坛徽章:
0
5 [报告]
发表于 2009-03-24 17:01 |只看该作者
EOF 是什么?

论坛徽章:
0
6 [报告]
发表于 2009-03-24 17:02 |只看该作者
$1 和$2是参数的话 该参数在哪个地方可以看到?

论坛徽章:
9
2015亚冠之阿尔纳斯尔
日期:2015-09-10 16:21:162015亚冠之塔什干火车头
日期:2015-07-01 16:23:022015年亚洲杯之巴勒斯坦
日期:2015-04-20 17:19:46子鼠
日期:2014-11-13 09:51:26未羊
日期:2014-08-28 18:13:36技术图书徽章
日期:2014-02-21 09:30:15酉鸡
日期:2014-01-14 11:12:49天蝎座
日期:2013-12-09 17:56:53平安夜徽章
日期:2015-12-26 00:06:30
7 [报告]
发表于 2009-03-24 17:07 |只看该作者
原帖由 lijie5 于 2009-3-24 17:02 发表
$1 和$2是参数的话 该参数在哪个地方可以看到?

位置参数,先看基础篇吧

论坛徽章:
0
8 [报告]
发表于 2009-03-24 20:12 |只看该作者

回复 #1 lijie5 的帖子

两个EOF之间包含的是ftp下的子命令
$1,$2.....$n是位置变量
以你的题目为例假设文件名是autoftp.sh
你以autoftp.sh 10.1.1.1 admin admin /root
对应关系是     :$1         $2       $3      $4

论坛徽章:
0
9 [报告]
发表于 2009-03-24 20:22 |只看该作者
这些定义好的位置变量 在哪里能看出来
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP