How to transfer files with Tramp using scp or rsync - emacs

I've read the TRAMP manual and dozens of forums across the web but I couldn't find an answer to this question. I am trying to set up a link in org-mode that transfers a file from a remote server to my local machine (or vice-versa).
According to the manual I have to write something like
/scp:user#host:filepathonremotemachine
and that's it. No specification of where the file should be moved to, which is weird.
I've tried to do it this way and it simply opened the file (as if I was using ssh); tried other combinations also, without any luck.
There is a specific reason for why I am trying to do this with tramp and not a shell:command link. Any help is very welcome
UPDATE
Apparently TRAMP is less useful than what it promises. That leaves me with the shell:command link option. The problem then revolves around avoiding the openssh window that pops out. The closest solution I found was here and it resumes to setting up an ssh-agent. I am not very familiar with this procedure and I would prefer to use the authinfo.gpg authentication method. Do I have this option? Thanks.

Tramp itself offers just alternative implementations of native Emeacs functions. In this sense, it is dumb, as every library, because it doesn't know what the caller wants.
I'm not an org-mode specialist, but could you please show, which kind of link you have in mind? Without any remoteness, just a link which copies a file locally. Replacing local file names with remote ones will be easy then.
I assume, you need something like an external link, evaluating Lisp code. Like
elisp:(copy-file "/path/src" "/path/target")

The following works (for some definition of "works"):
* link to copy a file
[[shell:scp remote.host.com:/path/to/file /tmp][scp]]
But you must have arranged for passwordless login to the remote host beforehand (e.g. ssh-copy-id your public key to the remote): given that, there is no output in the org buffer, no openssh popup, just the standard question from org-mode asking if you really want to execute the shell command and the file is copied quietly to its destination.

Related

How to periodically 'touch' temporary files on remote server so the files don't get deleted

I log on to the remote server using SAS/Emacs. On the server, there is this space where I can save files for about a week. Unless I refresh or 'touch' those files again, they will get deleted after a week. Is there a macro or a code that I can execute whenever I open SAS/EMACS so that these files stay updated?
So far, I have used SSH to go on to the server and type 'touch /*' to keep it 'touched', but I am hoping there is a better/more efficient way to keep those files touched.
Assuming you're using EMacs Speaks Statistics to connect to SAS, then you have a couple of different options.
One is to modify ess-sas-submit-command to point to a script that first does your "touch" command and then starts SAS.
Another is to create an autoexec for SAS to do that for you, assuming you have rights to do so; you can add that to various locations in Unix or to the command line itself (depending on how you're launching SAS).
Even if you're not using ESS, the Autoexec method may work for you.
Note that, of course, your system administrator may not appreciate doing this, so do make sure this is permissible (unless that sysadmin is you!).

Thunderbird removes any attempt to make an extension

I might be a complete idiot, so please bear with me if I am.
I've been attempting to create an extension for Thunderbird.
I quickly googled for an official documentation and followed it as closely as I could. This way, I ended up with a simple result to test, which would, according to the documentation, work.
So I opened up Thunderbird, nothing.
I closed it again and went to see what I did wrong. However, Thunderbird had completely removed the folder I had.
I did this a few times more with the same result.
This is what my folder setup looked like:
%APPDATA%/Thunderbird/Profiles/[profile name]/extensions/
foobar#foo.bar/
install.rdf
chrome.manifest
chrome/
content/
foobar.xul
foobar.js
locale/
defaults/
preferences/
The contents of these files were, at my last attempt, literally copy/pasted from the documentation, only with altered filenames(both in code and in actual files), extension ID(both in code and the folder name), and maximum version tag.
What exactly am I missing here?
I absolutely agree with using proxy files for addon development. But if you followed the guide mentioned by Jonathan Protzenko, your structure would look more like this:
%APPDATA%\Thunderbird\profiles\[profile name]\extensions\
foobar#foo.bar
SomeDrive:\path\to\some\place\
foobar_dev_directory\
install.rdf
...
chrome\
i.e, the development directory is not located inside your profile. Instead, consider the proxy file
%APPDATA%\Thunderbird\profiles\[profile name]\extensions\foobar#foo.bar
SomeDrive:\path\to\some\place\foobar_dev_directory\
You must only enter the second line, and never forget the trailing \ as mentioned here (3, Note).
Also you should uninstall the addon (if you had one with the same id created and installed before). When you start tb the first time thereafter, you will be asked to allow exernal addons to be installed or something similar.
I got things working this way, hope this helps.
A second guess might be the following: you're obviously working on windows. Are you viewing files always with extension in windows explorer? If not or not sure, check the following:
In Windows Explorer under Organize \ Folder Options \ View deactivate Hide extensions for known file types.
Further, try using a proxy file named differently, especially without the top-level domain. I suspect this could be misinterpreted by windows as an extension. You should call your proxy file thus foobar#foobar.

Password on Emacs Boot Up

I was wondering whether there is a way to ask for a specific password when booting Emacs? I think I can ask for a pre-defined password which I can define in my .emacs file but I dont know how? I'm mainly interested to do this in an x- or graphical environment..
btw, I do know that the .emacs file can be seen and etc..but in my case it's not an issue.
I use epg to keep encrypted data in file. Then it simply loaded as normal emacs lisp file, as in my config. EPG will automatically ask for passphrase, and you can analyze return code of load function to determine, was loading successful or not
If I understand correctly, you are in a situation where multiple people share the same account on a computer -- that is, not only will they run the same emacs binary, they also have the same home directory where Emacs searches for the .emacs file.
It seems like you not only want to prevent others from reading the .emacs file, you actually don't want them to be able to run emacs at all.
Unfortunately for you, Emacs can be started with -q or -Q in which case the .emacs file is not evaluated at all. Thus any "protection" that relies on your .emacs file can easily be circumvented.
How about restricting access to the emacs binary instead? Maybe make it only executable for members of a certain Unix group (which of course is pointless if multiple people share the same account), or something along those lines. But note that this will not prevent them from installing their own local copy of Emacs.

Pre-existing set of 'useful' customizations for Emacs (CLI version)?

I'm sat here getting emacs into some sort of usable form, with line numbers, less annoying backup file handling and syntax highlighting. Intent on not repeating the process, I was going to push the entire set of changes into a git repository for easy re-use. But presumably somebody else has already done this and many people just use a 'standard' set of customizations? Is there a place I can simply download a tarball and extract it to my home directory and be done?
I work primarily with Ruby, Python, PHP and C, so don't need anything too magical.
Turning my comment into an answer as requested:
You can use this Emacs Starter Kit.

Why does making simple edits then uploading crash my site?

Whenever I alter (or even just resave without altering) a Perl file, it completely takes down our backend. I have no idea what the problem could be. Permissions are correct. Encoding is correct. Encoding is UTF-8. Transfer mode was ASCII.
I might not deal with Perl too much but I have no idea what the problem could be. The network admin hosting our website has no idea what the problem could be.
Text editors I tried: Dreamweaver, TextMate, Vim
Operating systems I tried: Mac OS X, Linux (Ubuntu)
FTP clients I tried: Transmit (Mac), Filezilla (Linux (Ubuntu))
It's not that it's bad code, I even tried to open and solely save and my backend still goes down.
The network admin told me that he ran the files through a dos2unix converter and it worked immediately. I of course tried this and it did not, more so it wouldn't make any sense, since I tried this in some of the most respected editors and I don't think it would make such drastic changes to the file type without any user input. (when I say respected editors Dreamweaver is not included in that sentiment).
I personally think it is some sort of server-side issue because I have crossed my t's and dotted my i's in regards to any possible client side issue but I have tried everything. Any opinions as to what the root of this problem is, and any possible solutions? Thanks in advance.
Try setting binary mode in your FTP client. That will allow you to experiment with different line endings (dos2unix) on the client side, without worrying about them being translated during transfer.
I've had this problem in the past and line-feeds were indeed the culprit.
Your editor and/or FTP program may be mangling the linefeeds.
Running dos2unix on the server is a good test as to the problem but not the cause.
Generate an MD5 hash of the file after each step in saving and transport to find where it changes.
You do not say what kind of framework/server you are using.
Maybe the server reloads the file while it is still being written by FTP or whatever? (I.e. that the file is not complete when the server reads it?)
Will a server restart fix the problem once the file is uploaded?
It sounds like you are using dos2unix before the transfer but the network admin is using it after. Perhaps it's doing something different in that case.
How many lines are in the file? What is the file size before and after you save it, after you transfer it, and after transfer and running dos2unix on it?
If this is just a line ending problem, you might point your network admin at http://www.perlmonks.org/?node_id=586942.
Response to rebra: No frameworks are used, and I don't know what kind of server this is on. This is basically a one man project on a shared host which was pretty horribly maintained and I'm trying to clean house.
Yeah that does make sense and I asked the server people about that, one of my first questions actually, but even if that is the case, I can't reboot via Plesk (kind of like cPanel). But thanks for that, you put into technical words/explanation what I was thinking of the whole time.