How to download a .sh file in command line
In comparison, 's cat-solution finishes in less than 0. Not very surprising, really. This is obviously silly, since without using external utilities, there's not much we can do with the downloaded file, not even make it executable. So you can also use SSH to upload to it. Which is functionally equivalent to downloading of software packages etc. As shown in this answer , you would execute the following on your local machine to place a file on your remote headless server:.
The disadvantage of the above solution compared to downloading is lower transfer speed, since the connection with your local machine usually has much less bandwidth than the connection between your headless server and other servers. To solve that, you can of course execute the above command on another server with decent bandwidth. To make that more comfortable avoiding a manual login on the third machine , here is a command to execute on your local machine.
See the explanations below for the reason. The command will ssh to your third machine intermediate-host , start downloading a file to there via wget , and start uploading it to target-host via SSH.
Downloading and uploading use the bandwidth of your intermediate-host and happen at the same time due to Bash pipe equivalents , so progress will be fast. For the -T -e none SSH options when using it to transfer files, see these detailed explanations.
This command is meant for cases where you can't use SSH's public key authentication mechanism — it still happens with some shared hosting providers, notably Host Europe. To still automate the process, we rely on sshpass to be able to supply the password in the command.
It requires sshpass to be installed on your intermediate host sudo apt-get install sshpass under Ubuntu. We try to use sshpass in a secure way, but it will still not be as secure as the SSH pubkey mechanism says man sshpass. In particular, we supply the SSH password not as a command line argument but via a file, which is replaced by bash process substitution to make sure it never exists on disk.
The printf is a bash built-in, making sure this part of the code does not pop up as a separate command in ps output as that would expose the password [ source ]. And that without using a temp file [ source ].
But no guarantees, maybe I overlooked something. Again to make the sshpass usage safe, we need to prevent the command from being recorded to the bash history on your local machine. For that, the whole command is prepended with one space character, which has this effect. Normally, SSH would then wait for user input to confirm the connection attempt. We make it proceed anyway. So we have to rewrite the typical wget -O - … ssh … command into a form without a bash pipe, as explained here.
Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. Ask Question. Asked 8 years, 4 months ago.
Active 2 years, 10 months ago. So when someone has a bug and tells a story instead of giving the relevant zeroes and ones, chances are they will never find a solution. There is nothing worse than having errors you don't see.
There are mistakes we make and IDEs do their best to notify us as we type. Things like syntax errors, missing semi colons, wrong data type assignment. These things happen and the compiler throws an error before we launch our application. The worse kind of errors are those that only happen in specific conditions. Andy Jun 20 :. Ibrahim Jun 20 :. Manish Oct 2 :. Ibrahima Diallo Oct 2 :. Manish I just tested it by downloading a jpeg file with curl, wget, and Invoke-WebRequest and the sizes are all the same.
There is no extra compression with Invoke-WebRequest , all it does is download the file as is. Ibrahim Oct 15 :. Ibrahim Jul 24 :. James Make sure you use -O and give it a path. Joel Oct 6 :. Ibrahim Oct 7 :.
Thanks for your comment. Shivani Oct 15 :. Sam Jul 7 :. But you can save some more time by pressing, ctrl-c then ctrl-v My hands are already on the keyboard, and I would rather do the mundane things on the keyboard and not think about them. Open PowerShell. Now run the curl command with the -O option to specify the file output. Sign up for the Newsletter. Here the screen grab,. Install GIT. After installation right click in your folder select GIT Bash Here see attached pic and use your sh command like for example:.
The error message indicates that you have not installed bash , or it is not in your PATH. If Windows is not central to your usage scenario, installing a free OS perhaps virtualized might be the simplest way forward. The second error message is due to the fact that Windows nominally accepts forward slash as a directory separator, but in this context, it is being interpreted as a switch separator. The most common way to run a. Cmder is a software package created out of pure frustration over the absence of nice console emulators on Windows.
It is based on amazing software, and spiced up with the Monokai color scheme and a custom prompt layout, looking sexy from the start. I was trying to set my region for my x-wrt r netgear router, I found the following worked for me, using bash on ubuntu on windows, you do have to enable subsystem found in windows features, and dev mode on. New feature in Windows - run bash on ubuntu on windows - available in Windows 10 "Insiders" builds after the Build conference:.
Personally I used this batch file, but it does require CygWin installed bit as shown. Just associate the file type. SH with this batchfile ExecSH.
BAT in my case and you can double-click on the. SH and it runs. Based on this original work. Set the below Path in the environment variables of System for the Git installation. Type ' sh ' in cmd window to redirect into Bourne shell and run your commands in terminal. Have you tried cd ing to the root directory where your. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to run. Ask Question. Asked 7 years, 1 month ago.
0コメント