在Makefile中包含一些SFTP命令 [英] Including some SFTP commands in a Makefile

查看:169
本文介绍了在Makefile中包含一些SFTP命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Makefile来创建我正在处理的论文的pdf。我也想使用make将最新版本上传到我的网站,这需要sftp。我虽然可以做这样的事情(在命令行上的话),但似乎在make,EOF被忽略,即

I use a Makefile to create pdfs of papers I'm working on. I'd also like to use make to upload the latest version to my website, which requires sftp. I though I could do something like this (which words on the command line) but it seems that in make, the EOF is getting ignored i.e., this

website:
    sftp -oPort=2222 me@mywebsite.com << EOF
    cd papers
    put research_paper.pdf
    EOF

错误消息

cd papers
/bin/sh: line 0: cd: papers: No such file or directory

我认为是papers不存在于你的本地机器上, '正在本地执行,而不是远程执行。

which I think is saying "papers" doesn't exist on your local machine i.e., the 'cd' is being executed locally, not remotely.

推荐答案

你不能(通常)在一个Make食谱中的多行上放置一个命令,所以这里的文档是一个no-go 。请改为尝试:

You cannot (normally) put a single command on multiple lines in a Make recipe, so here documents are a no-go. Try this instead:

website: research_paper.pdf
    printf 'cd papers\nput $<\n' \
    | sftp -oPort=2222 me@mywebsite.com

目标显然取决于PDF,它也是一个明确的依赖。

The target obviously depends on the PDF, so I made it an explicit dependency, as well.

这篇关于在Makefile中包含一些SFTP命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆