0

I have a JavaScript file that I want to run on a remote server. I dont have access to move the script to the server so I want to be able to run the script from my local machine with a remote side argument (filename). Essentially its a script that takes in a file name as an argument and then searches the file that's on the remote server. I tried the following but I get an error code 1. Will i need to write a bash script instead?

ssh [email protected] 'node filename' < script.js

Here is an image of the script on my local machine and the text on the remote server

4
  • If you have ssh access to the remote server it usually means you also have access to scp your script to the remote server. Are you sure you don't have scp or sftp access? Commented Jul 14, 2020 at 13:52
  • @slebetman I do have sftp access, but im not allowed to move my script to the server for admin reasons. I was thinking I could still run the script from a local machine and get the results i want. Commented Jul 14, 2020 at 13:54
  • I don't know if it would work, but you could try to cat the script to node like this answer... Honestly, this is less a JavaScript question than it is an ssh or bash question. Commented Jul 14, 2020 at 14:00
  • @slebetman yeah I tired the cat method, doesnt seem to work either. I agree its more a bash question than a JS. Thanks for the help though. Commented Jul 14, 2020 at 14:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.