If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

connect and forward ftp connections

Ok well I posted this idea in my raspberry pi forum but there is not enough of a support base yet i think to help me with this. I have a small raspberry pi computer which runs a version of debian. Below you will find my original description

Ok I have an idea that I have been wanting to implement but not entirely sure how to. Here is a basic description.
I have a server that gets used for downloading files where ever i want. It's like dropbox but my own personal one. Unfortunately me keeping it on 24/7 is a lot of electricity/money. I ordered a pi thinking I can do this which i am hoping it is possible. My server is just a giant ftp server.

My idea: If no one is connected it goes to sleep to save power. then when someone tries to connect it starts up and lets the person in.
Since Rpi's don't use much I chose this as a viable option to run 24/7. My plan is to create a script /ftp server on the Rpi. When someone tries to connect the Rpi see's that catches the connection and tells my server to wake up. While it is doing that it "holds" the connection then once the server is up it will forward the connection to the server as if it was on originally.
Hopefully this makes sense? yes?

Right now i have scripts in place on my main server that checks every 5 min to see if someone is connected if not it goes to sleep
I also found an article on how to use the Rpi's GPIO pins to turn on a LED which is written in python.http://tinyurl.com/7ww3gkw
This is why i posted it in here. In theory I just have to modify the code a tiny to have it turn on my server via the regular power button.
I can easily setup an ftp server on the RPi.

The problem I have is, I have no clue how to "hold" the connection of the incoming FTP then forward it.
There are a few requirements for this pretty much as I see it.
1 it has to accept any ftp connection with any username and password
2 once it runs the script to power on the server it has to check to see when it is ready
3 while its powering up it has to "hold the connection"; maybe give a message say please wait.
4 once it's up and running it has to take the existing connection and forward it to the FTP server; then the other FTP server will check the username and password and continue like it was never off.
5 if the server is already on the RPi should automatically forward the connection without a message /run the scripts

Do you guys have any suggestions on how to even start the FTP section? I think I can manage with the turn on part/script through the GPIO pins

Currently I have the script to turn on my server and turn off my server. The turn off script is actually on the server and the turn on is on the raspberry pi.

Someone suggested essentially an echo server. So I decided that java is universal (i think?) I will write it in that. When normally I write things in PHP but can't really do that with this type of project.
Currently I have a "echo server" that can run in my eclipse

I am able to telnet into it at a specified port and type w/ then it writes it to a log. A few things that I don't know are
1: when I run it the first line will always have "ˇŻˇŻ ˇŻˇŻ'ˇżˇŻˇż" in front of it then what ever i type. So example if I type hello for the first time upon connecting it will have "ˇŻˇŻ ˇŻˇŻ'ˇżˇŻˇżhello" if i type hello again, it will show up just "hello"

i am not sure what that is. I am guessing that it would be because either 1 its null or 2 that is what telnet sends to connect to the socket. At any rate is there anyway to clear/flush this?

2 I have tried to look up some java ftp libraries but all i find are client libraries is there any libraries out there that you know of that I could use? because when i try to connect to the socket via FTP it times out because it doesn't get a response. (obviously since i haven't set it up.)

Why not just run the server on the raspberry pi? An idea you could try is to run a ftp server on the raspberry and a samba server on the other computer.
On the raspberry have your main ftp directory as /samba. Then when the main computer turns on your samba server will start and thats where you files will be pulled from.
Just have a ftp banner saying refresh in 30 seconds. Then write a bash script to monitor the connection log. When someone connects it checks to see if the server is on if not it runs your power on command which will then start you samba server.