Andrew Wright Andrew Wright - 5 months ago 8
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


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