with SFTP - how to cd and lcd with one command?

1

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?

John

Posted 2012-08-23T14:51:08.560

Reputation: 673

Answers

2

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.

Daniel Andersson

Posted 2012-08-23T14:51:08.560

Reputation: 20 465

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 – 2012-08-23T15:43:43.840