使用ssh远程处理文件

时间:2014-11-25 19:44:44

标签: linux bash ssh remote-access

我有这个report.tex文件,我将其转换为pdf,如下所示:

latex report.tex
dvips report.dvi -o report.ps
ps2pdfwr report.ps report.pdf

这些命令放在名为linux_build

的文件中

这很有效。但是,这适用于我的Linux机器以及我在Mac上完成的大部分工作

我检查了MacTex,这是巨大的(> 4GB)所以我决定远程处理乳胶文件(所以在我的Mac上工作,并在我的Linux计算机上构建)。像这样:

ssh latex@192.168.2.8 "cd build && ./linux_build" < report.tex
scp latex@192.168.2.8:build/report.pdf .

所有这一切都有效,除了一件事:

latex report.tex

该命令只是在磁盘上查找,而不是某些输入流/管道。正是在这一点上,我不确定如何解决这个问题。有什么建议吗?

3 个答案:

答案 0 :(得分:2)

scp report.tex latex@192.168.2.8:/home/Jeanluca/build
ssh latex@192.168.2.8 "cd build && ./linux_build" < report.tex
scp latex@192.168.2.8:build/report.pdf 

首先尝试发送您的tex文件。到构建目录的完整路径。

答案 1 :(得分:2)

I know your frustration. It grew so big that I put together a small script which efficiently runs LaTeX on a remote server.

It prestarts LaTeX on the remote end with the preamble of the previous run such that LaTeX has already loaded the required packages and is ready to go when changed contents arrives, and starts streaming the resulting PDF file immediately (before LaTeX has finished writing to it). Also dependencies (images, included source files etc.) are transparently handled.

Maybe you too find it useful: https://github.com/iblech/sshlatex

无需安装。执行很简单:

  

$ sshlatex ssh.example.org foo.tex

答案 2 :(得分:0)

如果latex支持从标准输入读取,则可以这样做。

可能只是latexlatex -或可能latex /dev/stdin将其伪装成本地文件。

如果这不起作用,则需要首先传输文件。