如何使用 Bash 从互联网下载文件到 Linux 服务器

我最近不得不升级到 VPS 服务器(HostGator Linux) ,因为我想运行一个比普通 PHP db 操作稍微复杂一点的脚本。我正在尝试安装一个 JDK 和 ApacheAnt (如果需要的话,可以在服务器上编译 Android 应用程序)。

我看了 Linux Bash 的教程并开始使用它。我目前正在尝试将 Java (带有 JDK 和 JRE)安装到服务器上。

我正在跟随这个页面上的教程: Http://www.oracle.com/technetwork/java/javase/install-linux-64-self-extracting-142068.html

然而,我不知道在这条线上该做什么:

  1. 下载并检查下载文件的大小。

    您可以下载到您可以写入的任何目录。

如何从命令行下载 Java?

如果有关系的话,我正在运行 CentOS v5.8

234339 次浏览

You can use the command wget to download from command line. Specifically, you could use

wget http://download.oracle.com/otn-pub/java/jdk/7u10-b18/jdk-7u10-linux-x64.tar.gz

However because Oracle requires you to accept a license agreement this may not work (and I am currently unable to test it).

I guess you could use curl and wget, but since Oracle requires you to check of some checkmarks this will be painfull to emulate with the tools mentioned. You would have to download the page with the license agreement and from looking at it figure out what request is needed to get to the actual download.

Of course you could simply start a browser, but this might not qualify as 'from the command line'. So you might want to look into lynx, a text based browser.

Using wget

wget -O /tmp/myfile 'http://www.google.com/logo.jpg'

or curl:

curl -o /tmp/myfile 'http://www.google.com/logo.jpg'