0

Sort of an odd question, but is there some way that I can operate on remote resources as UNIX files?

E.g. I'm looking for some way to do tasks like the following:

head ssh://hostname:/path/to/file.txt
cat http://domain.com/file.html > local-file

I strongly suspect that the answer is no. Any hints in attempts at this sort of thing are also encouraged

2 Answers 2

1

Natively, there is no such capability in SSH.

However, you can achieve much the same thing with SSHFS, which lets you mount a remote, SSH-accessible file system and then act on it locally as if it were a local resource.

You could also establish an SSH tunnel to proxy some other method of network sharing, such as NFS, SMB, or CIFS, which would again achieve a similar end result.

0

For SSH, what you can do is run the command non-interactive on the remote system:

ssh hostname "head /path/to/file"

This allows allows you to redirect the output into process on your local machine:

ssh hostname "cat /path/to/file" | head

The head here is executed on your local machine. You can also take local output and redirect it into an SSH session:

cat /local/file | ssh hostname "head > /remote/file"

This would take the content of your local file, pipe it through the SSH connection into a remotely running head, and write the output of head to a file on the server.

To access HTTP (and HTTPS) files and further process them locally the tool of choice is typically curl:

curl http://domain.com/file.html > local-file

Here curl is run locally and fetches the HTML file for you to work with. It does not allow you to change the remote files though, as this is not a feature of the HTTP protocol.

You must log in to answer this question.

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