Page 1 of 1
Execute Command SSH - "%1"
Posted: Mon Mar 31, 2025 8:58 pm
by RunDontStop
The "%1" variable in Execute Command references the file path on the computer running Switch. I am using SSH to execute the command on a remote computer. So the argument "%1" needs to be different for the remote computer. The shared folder on the remote Mac is the folder just before Execute Command in the flow. On the host Switch Mac the path is defined as:
/Volumes/[Sharename]/[Filename]
But on the remote Mac it is:
/Users/[username]/Documents/[Sharename]/[Filename]
because the shared folder is in that mac's Documents folder.
So I need "%1" to be the path in the context of the remote Mac, because it is the one executing the command. So, is there another argument that might work, to use instead of "%1"? Or, some way to alter "%1"?
I was able to create a workaround. I can change the folder just before Execute Command to be on a different server, a third server. That makes "%1" have the same definition on both Macs. Is that the best solution?
Re: Execute Command SSH - "%1"
Posted: Tue Apr 01, 2025 8:19 am
by freddyp
I am interested in learning more about what it is you are running as a remote process.
I can think of two alternatives where file paths will not be a problem. The first one is to use the Switch Remote Processing API:
https://www.enfocus.com/manuals/Develop ... index.html
This is a good choice if you have a job that requires some sort of processing and the resulting file has to be sent back into Switch.
The second one is to set up a small web server (with NodeJS you can do that with very few lines of code) to which you PUT/POST something and from the web server you do the processing you need, either by using NodeJS code, either by spawning a command line that runs whatever it is. This is a good choice if you only need to pass on metadata, or if the file you upload does not have to come back into Switch.
Re: Execute Command SSH - "%1"
Posted: Wed Apr 02, 2025 1:22 am
by RunDontStop
Thank you for this information.
My idea was pretty simple - I have another mac that can perform tasks such as printing or file conversions. By using ssh I can let the other Mac do this type of work and leave less for the Switch Mac to do.
It is more difficult if the file needs to return to Switch and continue on as the same job with metadata intact. For example, a file conversion. If I use Execute Command to convert the file, using ssh on the remote Mac - I can't seem to use "%2" as an argument. I figured out why. %2 is a path defined on the local machine (I used echo to a text file to learn this). This means the %2 variable can't make sense to the other Mac.
I can use %1 if the Execute Command input folder is a network folder. For something like printing a file, it works great. So I can let the other Mac be a print server. Maybe there is some way to expand the possibilities. I will read up on what you have given me. Thank you.
Re: Execute Command SSH - "%1"
Posted: Wed Apr 02, 2025 3:13 pm
by Terkelsen
If it's "only" a matter of preserving the metadata you could export the metadata as xml before sending the file to the other Mac and then inject the xml again into the file, when it returns. I have done that with files being send to Zünd PrepareIt and used the free app "Inject XML" to restore the metadata, and that works just fine. This way you only need a simple network folder connection between the two computers.
Re: Execute Command SSH - "%1"
Posted: Wed Jun 04, 2025 9:02 am
by Thesent
freddyp wrote: ↑Tue Apr 01, 2025 8:19 am
I am interested in learning more about what it is you are running as a remote process.
I can think of two alternatives where file paths will not be a problem. The first one is to use the Switch Remote Processing API:
https://www.enfocus.com/manuals/Develop ... index.html-
geometry dash
This is a good choice if you have a job that requires some sort of processing and the resulting file has to be sent back into Switch.
The second one is to set up a small web server (with NodeJS you can do that with very few lines of code) to which you PUT/POST something and from the web server you do the processing you need, either by using NodeJS code, either by spawning a command line that runs whatever it is. This is a good choice if you only need to pass on metadata, or if the file you upload does not have to come back into Switch.
This is exactly the kind of answer I was looking for. Thank you for making it so easy to grasp. Really appreciate your help!