Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using SFTP via terminal to connect to a server to upload and download files. I often find myself typing statements like this:

cd website/theme/drupal7default/assets/css
lcd website/theme/drupal7default/assets/css
put mainstyle.css

It would be much better if I could have one command that can perform both a cd and lcd. So that I can do something like:

cdboth website/theme/drupal7default/assets/css
put mainstyle.css

This will make sure my lpwd and pwd are the same. Does the command I'm looking for exist? And if the command does exist, what is it?

share|improve this question
up vote 2 down vote accepted

Within sftp the easiest way is probably to use the arrow to return to previous command, then Home or Ctrl+A to go to the beginning of the line, then L Enter. That is:

  • Home L Enter

For your use case perhaps the internal SFTP client is not the smoothest way, though. You don't mention OS, but if it concerns *nix, then using an SCP wrapper script directly might be a simple way to save time in the end, creating e.g. myupload and mydownload that attempts to upload or download the file given as argument to/from the server respectively, automatically deciding the correct paths from some given base project paths. Set up key based login so you don't have to enter a password every time.

Another pro with using SCP from the command line on *nix as compared to the SFTP client is that you will be in a familiar shell environment, most likely Bash, and have access to regular navigation tricks among the commands such as tab completion, command repetition, brace expansion, etc.

Personally I prefer version control systems for these kinds of tasks. It will give you simple uploading using e.g. a commit hook, and version control is very handy for code projects. I don't know exactly what you are doing so it might not fit perfectly, but if you like, take a look at e.g. Mercurial or Git.

share|improve this answer
I agree with everything you said. Their systems admin disabled my ssh access. I think that's why when i run scp command, i get permission error. This system hasn't installed version contorl yet. – John Aug 23 '12 at 15:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .