【问题标题】:How to run multi commands in one sh file?如何在一个 sh 文件中运行多个命令?
【发布时间】:2018-06-29 23:01:46
【问题描述】:

我有一个 mac 操作系统和 我的问题是关于“如何在一个 sh 文件中运行多个命令?”,如下所示:

#!/bin/bash
ftp 
open domain.com
user
pass
cd /public_html/test_folder
lcd /Users/mac/downloads
mput file
a

此命令用于:

  1. 打开 ftp
  2. 连接到我的网站
  3. 输入用户名
  4. 输入密码
  5. cd
  6. lcd
  7. mput
  8. a
    我在每一行的末尾添加&&,但没有工作他在命令行号 2 中开始和停止

    对不起,我的语言不好:(

【问题讨论】:

标签: bash macos shell terminal sh


【解决方案1】:

使用lftp,非常适合ftp脚本,当需要重新连接+继续文件传输,ssh/scp传输等时。

应该是这样的:

#!/bin/bash
## note: mput: -c (retry+continue); run: lftp -c 'help mput' to see help
lftp -c 'mput -c -O ftp://name:passd@server.com/path/ file1.txt file2.txt'

或者,您可以编写lftp 脚本,示例(注意:mirror -R = 上传):

#!/usr/bin/lftp -f
open ftp://ftp.server.com
user name passwd
cd /remote/path
lcd /local/path
mirror -R folder

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-26
    • 2012-03-07
    • 1970-01-01
    • 1970-01-01
    • 2017-08-08
    • 2022-11-04
    • 2021-12-14
    • 2020-03-16
    相关资源
    最近更新 更多