简体   繁体   中英

Download shell file with wget

I am trying to download the shell file with the wget tool. When I am trying to download the particular .sh file, the file named .sh is getting downloaded, but the content shown in the file is the HTML , not the actual file content. Hence it is downloading the HTML page provided as an input. The scenarios are as follows

wget command

wget --user=username --password=password https://some_url/Required_shell.sh -P /root/Desktop/


When I directly copy the URL used in wget in the browser, it downloads the file, but same case not happens with wget tool.

URL pasted in browser

https://some_url/Required_shell.sh

Output with wget tool

Required_shell.sh with HTML content, not the required shell file.

Some websites can disallow you to download its page by identifying that the user agent is not a browser. So you can mask the user agent by using –user-agent options and show wget like a browser as shown below.

wget --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12" https://URL/TO/DOWNLOAD

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM