Find the answer to your Linux question:
Results 1 to 10 of 10
Hello folks. Im having a little trouble trying to figure this out. I have 2 shell accounts, lets call them A and B. In A's server, I have internet access, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Apr 2005
    Location
    South America
    Posts
    152

    Redirecting Output for a Download....


    Hello folks.

    Im having a little trouble trying to figure this out.

    I have 2 shell accounts, lets call them A and B.
    In A's server, I have internet access, but no access to the shell from home...
    In B's server, I dont have internet access, but I can access it from home (and I can reach A's server)

    So a little ASCII schema would look like this

    Code:
    Teh Internet
    |
    |
    |
    A-----------------B
                      |
                      |
                      |
                    Home
    So as you can see, the only way to access A from home, is connecting to B and trying to call a remote script (php) on A's public_html

    So, since B has no internet access, and I need to download something through A... how would I somehow redirect wget's output or something, so that I can call wget from a php script (dont know if possible to run a wget normally because of apache's user permissions), and then have that script to be called from B and store the contents on B server?
    Something like an on-the-fly download using A as a guinea pig...
    This is the ASCII schema

    Code:
    http://internetserver.org/file.tgz
    |
    |
    |
    A-------------->B-------->B's server's Hardrive
    My guess with wget would be somehow redirect its output... so that the file is not stored on disk but rather redirected to stdout and that would be my php script streaming the file straight to the client (maybe a wget call on B)
    But the problem as I said before is that Im not sure about permissions (notice, I cant store anything on A, since all I can access is A's public_html)

    Obviously I have access to A from collegue... but I need to somehow make it download stuff at night when Im home, since Im still on dialup... you get what I mean, like I cant download knoppix DVD version while everybody on the computer labs is wasting the bandwidth at day

    So thanks a lot friends, I know a little big, but well, I tried to explain it the best I could

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    I don't know if this will help, but you can use curl instead of wget, because curl writes to stdout by default, so you can pipe it out to whatever it is you want.

  3. #3
    Linux Newbie
    Join Date
    Jul 2005
    Location
    Chd,India
    Posts
    135
    Let me know if i got it right!
    You can run a script on your A account that allows you to specify the file to download and then gets the file through A internet.
    But you dont have permissions to write to your account at A(how come ? if you have an account u should be able to store something there)

    So you want to redirect the file to B.

    Well i think there is a LWP module in perl that allows you to store the contents of a web page in a scalar variable.Your perl script can then transmit the contents of that variable over the connection between A and B
    The strong shall live and the weak will die
    In the end,only the fittest survive in this world
    - Shishio Makoto

  4. #4
    Linux Newbie
    Join Date
    Apr 2005
    Location
    South America
    Posts
    152
    Quote Originally Posted by lakerdonald
    I don't know if this will help, but you can use curl instead of wget, because curl writes to stdout by default, so you can pipe it out to whatever it is you want.
    Mmmm... curl, yeah Ive used it from C before, so Ill check if the apache server on A has the extension installed...

    Quote Originally Posted by gagan_goku
    You can run a script on your A account that allows you to specify the file to download and then gets the file through A internet.
    But you dont have permissions to write to your account at A (how come ? if you have an account u should be able to store something there)
    Hehe, thats exactly the problem. Right now, FYI, Im posting this reply from A :P But I need to access it from home... and I cant (outside connections disabled by the root) so the only way to do it, is to call a script on my public_html
    I hope thats clear now.

    Regarding the LWP module in perl... well thanks, Ill check that out too, though Ive never used it as a CGI... so I think that might be a problem, and Id be better off using php

    Edit
    Sad day for human kind cURL is not installed on A's server...

  5. #5
    Linux User Stefann's Avatar
    Join Date
    Nov 2004
    Location
    Boise, ID
    Posts
    340
    I'm thinking you should use a wget and scp combo, wget to get the file from teh interwb, and scp to copy the file.
    Nothing is worse than ten penguins fighting over which is better, vi or emacs.
    Registered Linux User #404402
    Finally I'm back on LF after a long while.

  6. #6
    Linux Engineer
    Join Date
    Jan 2005
    Location
    Chicago (USA)
    Posts
    1,028
    How are A and B connected? Does B have a drive mounted on A? Then it's just a matter of adding "-P MOUNTPOINT" to wget.

  7. #7
    Linux Newbie
    Join Date
    Apr 2005
    Location
    South America
    Posts
    152
    Quote Originally Posted by Stefann
    I'm thinking you should use a wget and scp combo, wget to get the file from teh interwb, and scp to copy the file.
    But how could I do this on-the-fly without the need for writing to disk?

    Quote Originally Posted by a thing
    How are A and B connected? Does B have a drive mounted on A? Then it's just a matter of adding "-P MOUNTPOINT" to wget.
    Nope, A and B are just different servers... connected internally (well dont know the tech term in english)... something like a huge intranet inside collegue.


    I think at some extenct I solved the problem for small files (<50 Mb since 50 is my quota )....
    Code:
    <?php
    $file=$_GET&#91;'file'&#93;;
    system&#40;"wget -cb $file"&#41;;
    ?>
    ... and I give the public_html write permissions for all users...
    But I still have the problem of downloading a Linux distro and the like

  8. #8
    Linux User Stefann's Avatar
    Join Date
    Nov 2004
    Location
    Boise, ID
    Posts
    340
    Code:
    <?php
    $file=$_GET&#91;'file'&#93;;
    $handle = fopen&#40;$file, "rb"&#41;;
    $contents = stream_get_contents&#40;$handle&#41;;
    print $contents;
    fclose&#40;$handle&#41;;
    ?>
    Something like this may work, I haven't used PHP in a while but I think this will work.
    Nothing is worse than ten penguins fighting over which is better, vi or emacs.
    Registered Linux User #404402
    Finally I'm back on LF after a long while.

  9. #9
    Linux Newbie
    Join Date
    Apr 2005
    Location
    South America
    Posts
    152
    Quote Originally Posted by Stefann
    Code:
    <?php
    $file=$_GET&#91;'file'&#93;;
    $handle = fopen&#40;$file, "rb"&#41;;
    $contents = stream_get_contents&#40;$handle&#41;;
    print $contents;
    fclose&#40;$handle&#41;;
    ?>
    Something like this may work, I haven't used PHP in a while but I think this will work.
    Hahaha... well you make me feel dumb because I just used something like that for a mod I made for phpBB.... dumb dumb I am :P

    And yep, I think thats teh winna

    So thanks a lot Stefann and y'all folks for your help, appreciate it a lot
    Cheers!

  10. #10
    Linux User Stefann's Avatar
    Join Date
    Nov 2004
    Location
    Boise, ID
    Posts
    340
    Quote Originally Posted by darklordsatan
    Quote Originally Posted by Stefann
    Code:
    <?php
    $file=$_GET&#91;'file'&#93;;
    $handle = fopen&#40;$file, "rb"&#41;;
    $contents = stream_get_contents&#40;$handle&#41;;
    print $contents;
    fclose&#40;$handle&#41;;
    ?>
    Something like this may work, I haven't used PHP in a while but I think this will work.
    Hahaha... well you make me feel dumb because I just used something like that for a mod I made for phpBB.... dumb dumb I am :P

    And yep, I think thats teh winna

    So thanks a lot Stefann and y'all folks for your help, appreciate it a lot
    Cheers!
    80% of the code was in the PHP manual, I just took it, added the $GET variable, and had it print $contents instead of closing the file and doing nothing.
    Nothing is worse than ten penguins fighting over which is better, vi or emacs.
    Registered Linux User #404402
    Finally I'm back on LF after a long while.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •