Andrew Wright Andrew Wright - 2 years ago 73
Linux Question

Compiling code on external server (on which I don't have root access)

For the c class I am taking, the c code will be compiled and graded on a redhat linux system, and it is recommended that you ssh to the server, upload, compile and run. This is kind of a pain in the ass and I was wondering if anyone had any ideas on how to automate this, keeping in mind I don't have root access to the server. I'm trying to write a bash script, but I'm having trouble even getting logged in.

Edit: I would like a workflow of:
1) upload the code on the server 2) compile the code 3a) return the compiled file 3b) return compilation errors

Answer Source

Here's a simple script that uploads one file and compiles it. You should be able to expand on this to automate more of the workflow.

scp "$filename" "$servername:"
ssh "$servername" gcc -c "$filename"

You put this in a script file, and use it with:

./scriptname project.c
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download