cartonn
cartonn

Reputation: 8754

How to transfer file from Windows to Linux server, process it with shell script, and download results back

I normally do this using WinSCP: I transfer a .tex file from my local Windows machine to a Linux server. I run a script (on the server) to pdflatex the file for me. And I use WinSCP again to copy the output .pdf to my local Windows machine again. I would like to automate the copying process in my script.

So the first step is to copy file.tex from C:\Doc...\source to ~/Documents. I think I need to use the scp command, but the server sees my local machine as a remote machine. That's why I'm confused as to how the first directory needs to be specified:

$scp C:\Doc...\source\file.tex ~/Documents

doesn't work because the server doesn't know how to talk to my local machine. I have the same issue for the scp command I need to use to copy file.pdf back to my local Windows machine.

Can anybody help me with these two scp commands?

Thanks in advance!

Upvotes: 2

Views: 3165

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202594

You can use WinSCP in scripting mode. It (naturally) supports the upload/download. But it can also execute the shell script on the server with call command (with some limitations, which should not matter in your simple case):

winscp.com /log=winscp.log /command ^
    "open scp://username:[email protected]/" ^
    "cd /remote/path" ^
    "put my.tex" ^
    "call pdflatex ..." ^
    "get my.pdf" ^
    "exit"

(I'm the author of WinSCP)

Upvotes: 4

Related Questions