在Makefile中包含一些SFTP命令

时间:2015-09-05 12:02:03

标签: command-line makefile sftp

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

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

我认为是&#34;论文&#34;在您的本地计算机上不存在,即&#39; cd&#39;正在本地执行,而不是远程执行。

2 个答案:

答案 0 :(得分:2)

一些想法:

  • 使用每个Linux发行版和brew应该具有的ncftp:它会记住&#39; state&#39;所以[Table("Ipv_Base")] public class Ipv_Base { [Key] public int ipv_baseId { get; set; } public int companyId { get; set; } [ForeignKey("companyId")] public Company company { get; set; } public string ipType { get; set; } [Required] public bool registedAddress { get; set; } [Required] [DataType(DataType.MultilineText)] public string existingNotes { get; set; } [Required] public int numberOfAddresses { get; set; } [Required] public bool returnedAddressSpace { get; set; } [DataType(DataType.MultilineText)] public string additionalInformation { get; set; } // navigation properties public virtual IList<IpAllocation> requestedIps { get; set; } } [Table("Company")] public class Company { [Key] public int companyId { get; set; } [Required] public string name { get; set; } [Required] public string telephone { get; set; } [Required] public string regNumber { get; set; } // navigation properties to keep track of the models that belong to the company public virtual IList<Pa_Ipv4> pa_ipv4s { get; set; } } [Table("IpAllocation")] public class IpAllocation { [Key] public int ipAllocationId { get; set; } public int ipv_BaseId { get; set; } [ForeignKey("ipv_BaseId")] public Ipv_Base ipv_Base { get; set; } [Required] public string allocationType { get; set; } [Required] public string subnet { get; set; } [Required] public string cidr { get; set; } [Required] public string mask { get; set; } } public class Pa_Ipv4 : Ipv_Base { public Pa_Ipv4() { ipType = "pa_ipv4"; } } 变得不必要了
  • 如果可能,请使用cd代替scp
  • 编写一个简单的shell脚本来执行EOF业务并调用

对于它的价值,这是我的脚本将tarball推送到CRAN winbuilder - 并将目标目录和脚本作为sftp的参数。

ncftpput

然后我做#!/bin/bash function errorexit () { echo "Error: $1" exit 1 } if [ "$#" -lt 1 ]; then errorexit "Need to specify argument file" fi if [ ! -f ${1} ]; then errorexit "File ${1} not found, aborting." fi ncftpput win-builder.r-project.org /R-release ${1} ncftpput win-builder.r-project.org /R-devel ${1} 然后关闭......

答案 1 :(得分:1)

你不能(通常)在Make配方中的多行上放置一个命令,所以这里的文件是禁止的。试试这个:

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

目标显然取决于PDF,所以我也明确依赖它。