Note : instead of use the full path to the putty executable, you can define an environment variable for putty in windows and then use it as %putty%. The entire command can be executed on the command prompt (cmd.exe) in windows easily, e.g: C:\path\to\putty.exe -ssh -pw "password" -m "C:\path\to\command_sh_script_file.sh"Ĭ:\Program Files\Putty\putty.exe -ssh -pw "ComplexPassword" -m "C:\Users\Admin\Desktop\command_file.sh" This option is not available in the file transfer tools PSCP and PSFTP. In particular, it is known not to work with certain ‘embedded’ servers, such as Cisco routers. With some servers (particularly Unix systems), you can even put multiple lines in this file and execute more than one command in sequence, or a whole shell script but this is arguably an abuse, and cannot be expected to work on all servers. T he -m option expects to be given a local file name, and it will read a command from that file. The structure of the command is the following: putty.exe ] Now that your script file is ready and (theoretically) you know what you want to achieve with it, we just need to execute it and save many precious time. Executing the script using PuTTY from the windows command prompt Now that our script is ready, we just need to learn how to execute it automatically. Start reading more about all the things that you can do with. # Real path of folder = /var/www/vhosts/myproject/deleteMe # Therefore the path is relative to where we are located. # Note: the folder name is "deleteMe" and it is inside /myproject # Delete the content from a folder in the project # it contains where your project is located We recommend you to test only with the previous script and when you have more experience, try with your own. sh file to be executed, be sure of what do you to prevent any damage that you can do to your server. If you want, start creating your own, the following example shows a basic interaction with commands that you normally execute using putty (subversion command svn update): Read -rsp $'Press any key to continue.\n' -n1 key # Don't close putty to see the output of the date In this example (the most basic), we are going to print the date in the Putty console. sh extension ( command_file.sh) somewhere. To get started, create a file somewhere with. Ask yourself if you trust the party that has supplied this file, ask yourself if you are sure that have downloaded the file from the same place as you thought, maybe even have a glance inside to see if something looks out of place ( although that requires that you know something about *nix commands and bash programming).Ĭonclusion : execute only commands that you know, and only if you know how they work. But this is partially because of strong need for security.īasically when you download and run a bash script, it is the same thing as somebody telling you "run all these commands in sequence on your computer, i promice that results will be good". You may find it weird that you must perform another task manually in order to execute a file. This file format is commonly used for Unix shell files, created by the Unix shar utility program. sh file is a shell script which you can execute in a terminal. In this article, you'll learn how to execute a shell script from windows to a remote server using PuTTY and the windows command prompt. You can automate your server tasks without type all that you need everyday (go to a folder, do something there, then exit, navigate to other etc). PuTTY is an SSH and telnet client.Īlthough use the console is already simple and easy you are most likely to make mistakes sometimes (and erase the project folder accidentaly). PuTTY doesn't need any introduction as its one of the widely remote console utilities.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |