Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running a script on a remote host using ssh

hostA shell: cat script.sh | ssh user@hostB

The script resides on host A and is run on host B using the above ssh command. So far it was good. But now the script has to read a file which also resides on the host A.

The question: Is it possible for the script to read the file from host A while running on host B?

Any help appreciated.

share|improve this question
    
You mean to say that you are executing a local script on a remote host using SSH and you want to read a file that is on the remote host? Can you update your post to make this clear? – Ganesh R. Jul 20 '13 at 18:14
    
No, I am executing a local script on a remote host using SSH and I want to read a file that is on the local host, i.e. the script and the file to be read by the script are both on the local host. – user2602696 Jul 21 '13 at 6:48

You could either copy the file to the remote host (e.g. to /tmp) before running your script, or establish a ssh connection from the remote to the local host to get the file contents.

For the latter, you will likely need to use public-key-based authorization from the remote to the local host, so the script can run without you having to type in your password.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .