Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
How do I run shell commands as [email protected] within a shell script?
Post Body

Hi all! 3 week Linux noob here.

I'm writing a shell script to synchronize a local folder to my school's server, then log me into the server in the correct directory to test everything before turning it in. I know it's totally engineer of me to do, since it's a 3 second task, but I do it multiple times in a week... so why not save some time?

So far, I have the synchronization part down:

echo "Which lab number are you working on this week?"
read lab
rsync -rutv ~/BIOCOMP/LAB_$lab [email protected]:~/BIOCOMP
ssh [email protected]

All of that works really well. But I run into problems when I want to test all of my programs on the server. It turns out I can't just feed shell commands to it and expect it to work! The shell only works "locally", and any further commands I input don't run until I exit the server.

Once inside the server, I would like to run:

cd BIOCOMP/LAB_$lab
clear
ls
done

The idea being that I am now logged into the server and have a list of the programs I have written at my fingertips, ready to be tested.

How do I run programs as [email protected]?

Author
Account Strength
100%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
69,577
Link Karma
8,834
Comment Karma
60,688
Profile updated: 4 days ago
Posts updated: 5 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
8 years ago