views:

503

answers:

13

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?

+10  A: 

CURL

Randolpho
+2  A: 

lynx -source

cube
+2  A: 

Is curl installed?

eduffy
+2  A: 

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 [email protected]:folder/file.flv ./

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

sirlancelot
Abs clearly states it's from another server.
Randolpho
@Randolpho - ummm, scp allows you to copy from another server. It's scp's sole function.
sheepsimulator
@sheepsimulator: you can only use SCP if you have *access* to the remote server, i.e. it's a host on which you have an account. I believe Abs does not have such. That said, on a second read of the question it could be interpreted that Abs has access to the remote host. Based on that, I'm rescinding my downvote.
Randolpho
@Randolpho, I found the question to be rather ambiguous as to whether he had authenticated access or not. I just gave my two-cents. Thanks for removing the downvote anyway :)
sirlancelot
No problemo. :)
Randolpho
+3  A: 
curl -C - -O http://www.url.com
amr
+2  A: 

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

sheepsimulator
+6  A: 
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"; } }'
bdonlan
This is clearly epic, but it seems to run and provide no feedback.
sheepsimulator
I never said it was a very /good/ option. But if you've got netcat and perl... (though, using LWP::Simple would probably be better if you have perl. this could be changed to use sed or awk or something instead easily enough though)
bdonlan
you can theoreticaly do it without netcat and without perl -- bash has tcp redirections and sed can erase the header. But i realy don't feel like writing it :-) look here: http://thesmithfam.org/blog/2006/05/23/bash-socket-programming-with-devtcp-2/
cube
GNU awk has TCP redirections too :) @cube: I didn't see your comment when I wrote my answer below, but that's pretty much the same as what I did.
ephemient
@cube, a number of distributions (including debian) disable bash tcp redirections - after all, that's stealing part of the filesystem namespace
bdonlan
@bdonlan: Or for security or size or something like that, more likely. It's not like "stealing" `/dev/{tcp,udp}/*/*` matters when there's no devices with those names.
ephemient
+1  A: 

Various ways,

  1. Python -- How not to fetch data over HTTP
  2. Perl -- File::Fetch module
  3. TCL -- ::http::geturl, has example at the end
  4. If you have the compiler and FTP works, get wget and compile it
nik
+2  A: 

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.

eduffy
A: 

Another possible alternative is aria2.

Troubadour
+2  A: 
ephemient
+2  A: 

I've been using: curl -o http://www.domain.com/file.flv

incidence
Why did the OP accept this answer? Many others mentioned curl a long ago and to top it all off the exact command given here is incorrect. Bizarre.
Troubadour
Hi,You should read: man curl. -o means writing output file to disk instead of giving it to stdout. :)
incidence
gotta encourage newbies!
Matt Joiner
A: 

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

Rishav Rastogi