JSilvanus
JSilvanus

Reputation: 145

SSH remote command executing a script

I have two hosts, hosts A and B. A has a script (generate) that compiles my thesis:

#!/bin/sh
pdflatex Thesis.tex

When running this command on host A (console window) it works perfectly.

I am basically trying to connect from host B to A and run the generation command as an ssh remote command. All the keys are properly set. When I run the command, I get the following:

hostB> ssh user@hostA exec ~/Thesis/generate
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
! I can't find file `Thesis.tex'.
<*> Thesis.tex

I tried adjusting the script so that it considers the directory:

pdflatex ~/Thesis/Thesis.tex

But because the Thesis.tex inputs some others files (images), I get an error message.

I presume the problem is some sort of enviroment that doesn't exist in remote commands. How do I fix this?

Upvotes: 1

Views: 326

Answers (1)

that other guy
that other guy

Reputation: 123640

ssh will run your command in your home directory. You probably wanted to run it in your ~/Thesis directory.

Just cd first and it should be fine:

ssh user@hostA 'cd ~/Thesis && ./generate'

Upvotes: 1

Related Questions