views:

90

answers:

1

My university has quite a lot files (like past papers etc) which I need to be on the uni network to access them. I ssh, using port forwarding, into the network and set my browser (Firefox) to go through that port. I know it would be quite easy to write something in most languages that would enter the command into a terminal, but which language/method could I use to make this happen? I expect some sort of scripting language could but I really know nothing about them, but I'd be willing to learn one just to have a little fun with this.

I'm using a cygwin terminal on Windows 7, if that will make a difference.

To neaten up my question: Which language would be best to acheive the above effect? Not necessarily the best, just possible and relatively simple to learn. I used the word best so I suppose I'll put a subjective tag.

EDIT: Just in case anyway wants to do this precise thing, I'll show my solution. I ended up using a batch file because a few things made the bash more difficult. Anyway, in order to SSH into the network and open a new firefox window with the proxy changed, I just have to open this batch file and enter my password.

cd C:/cygwin/bin
ssh -fND 9001 [email protected]
cd "C:/Program Files/Mozilla Firefox"
firefox -no-remote -P SSH_profile

Save as .bat

In order for this to work you need to set up a profile with name SSH_profile (or whatever) and set the connection settings to go through port 9001. The script will open use the ssh command in /cygwin/bin and enter in the information. You enter your password and then it goes to your firefox directory, uses those arguments which opens a separate profile with the connection settings changed (means you can view unaccessible files in one window and anything else you don't want to be on your uni network in another. Just close the windows when you are done.

Quite a specific case but I thought I'd share my answer in the hope of helping someone, some day.

+2  A: 

Since you are using cygwin, write a bash shell script.. If you don't want to rely on bash, powershell would be what you want, although you could probably get it working using a batch file.

This is exactly the kind of thing shell scripting is for.

Edit

You can change the firefox settings on the command line by passing the -override flag. This will let you have special settings for the invoked process.

Byron Whitlock
This is what I thought of first but I just wasn't sure. So I'll be able to change firefox connection settings with it?
Paul
Beat me to it. With a BASH script, you won't have to dive into learning another language (it's pretty much unix commands plus if/while/etc) like python/php/ruby/c/whatever.
rlb.usa
Thanks for the update, I should be able to do it now.
Paul