Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.