I have a scenario where I need to run a linux shell command frequently (with different filenames) from windows. I am using PuTTY and WinSCP to do that (requires login name and password). The file is copied to a predefined folder in the linux machine through WinSCP and then the command is run from PuTTY. Is there a way by which I can automate this through a program. Ideally I would like to right click the file from windows and issue the command which would copy the file to remote machine and run the predefined command (in PuTTy) with the filename as argument.
相关问题
- Is shmid returned by shmget() unique across proces
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
You can create a putty session, and auto load the script on the server, when starting the session:
At remote command, point to the remote script.
You can do both tasks (the upload and the command execution) using WinSCP. Use WinSCP script like:
Reference for the
call
command:https://winscp.net/eng/docs/scriptcommand_call
Reference for the
%1%
syntax:https://winscp.net/eng/docs/scripting#syntax
You can then run the script like:
Actually, you can put a shortcut to the above command to the Windows Explorer's Send To menu, so that you can then just right-click any file and go to the Send To > Upload using WinSCP and Execute Remote Command (=name of the shortcut).
For that, go to the folder
%USERPROFILE%\SendTo
and create a shortcut with the following target:See Creating entry in Explorer's "Send To" menu.