Question

My host allows limited access to SSH and Linux commands. However, I can't use Wget believe it or not.

I was hoping for something to download a file (.flv) from another server. Is there another command I can try?

If there isn't, I could probably make use of Python, Perl or PHP (favourite) to achieve a file download. Is it possible?

Was it helpful?

Solution

You can use the following command:

curl -O http://www.domain.com/file.flv

OTHER TIPS

echo -ne "GET /path/to/file HTTP/1.0\r\nHost: www.somesite.com\r\n\r\n" | nc www.somesite.com 80 | perl -pe 'BEGIN { while (<>) { last if $_ eq "\r\n"; } }'

Bash compiled with --enable-net-redirections is pretty powerful. (Zsh has similar features.) Heck, I'll even throw HTTP Basic Auth in here, too.

Of course, it's not a very good HTTP/1.1 client; it doesn't support chunked encoding, for example. But that's pretty rare in practice.

read_http() {
    local url host path login port
    url="${1#http://}"
    host="${url%%/*}"
    path="${url#${host}}"
    login="${host%${host#*@}}"
    host="${host#${login}@}"
    port="${host#${host%:*}}"
    host="${host%:${port}}"
    (
        exec 3<>"/dev/tcp/${host}/${port:-80}" || exit $?
        >&3 echo -n "GET ${path:-/} HTTP/1.1"$'\r\n'
        >&3 echo -n "Host: ${host}"$'\r\n'
        [[ -n ${login} ]] &&
        >&3 echo -n "Authorization: Basic $(uuencode <<<"${login}")"$'\r\n'
        >&3 echo -n $'\r\n'
        while read line <&3; do
            line="${line%$'\r'}"
            echo "${line}" >&2
            [[ -z ${line} ]] && break
        done
        dd <&3
    )
}

OTOH, if you have Perl's LWP installed, it should ship with a sample binary named GET

lynx -source

curl -C - -O http://www.url.com

Python script:

#!/usr/bin/env python
import os,sys,urllib
f = open (os.path.basename (sys.argv[1]), 'w')
f.write (urllib.urlopen (sys.argv[1]).read ())
f.close ()

where sys.argv[1] is the URL you're interested in.

If you're trying to download a file from a host you have authenticated access to, try using scp. It's like a normal copy but it is done through an ssh tunnel. I've found that hosts who allow "limited ssh" often still allow scp.

scp user@myhost.com:folder/file.flv ./

You will need to provide your user credentials. See scp documentation for more information.

Another tool that's out there that does similar stuff is snarf.

Use scp.

usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2

Various ways,

  1. Python -- How not to fetch data over HTTP

Another possible alternative is aria2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top