UNIX ftp command get, change default destination directory - unix

I know VERY little about UNIX commands, so I´ll do my best to explain what I want in plain English.
Though my mac´s Terminal, I am connected to an ftp account by:
ftp example.com
When I do:
get file.php
I download it to the users directory.
So now two related question:
1) How can I choose the download directory for this specific download
and
2) Choose the default destination directory for future download.

Use a second argument to get; e.g. get file.php path/to/dir/.
Use a command that's usually called lcd (for "local change directory"). Not all clients have this command, but most do (for example, lftp, a powerful ftp client, does).

Related

rsync How to preserve links on receiver

I've got dir per environment on receiver with links to some files.
This is because, some files are shared between environment.
So what I would like, when I'm doing a rsync from my remote host to my receiver, that the retrieve files are place following the links. But currently, my rsync replace my local links by the retrived files.
Is there a way to tell rsync to follow links on receiver hosts?
If those links are pointing to directories, you cas use -K option which works flawlessly.
Other thing is when you have on the receiver links pointing to files (not dirs).
I am afraid, currently there is no simple way how to preserve the links in the destination and amend the files they are pointing to with the contents of local links/files those point to.
You might be interested in the -L option if you are sending files links from source but want to copy contents they point to rather than links themselves. However, this would also remove the corresponding links in the receive destination and as mentioned earlier, just change the files they are pointing to.
Check out https://serverfault.com/questions/245774/perform-rsync-while-following-sym-links for more information.

Nautilus script: $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS empty for WebDAV folders

When writing a Nautilus script, $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS gives the path to the file whose context menu has been clicked, for instance /home/nico/test.txt.
But when the file is within a WebDAV share, the variable is empty.
Is it a bug?
How to get the path for a WebDAV file?
My script is intended to be used for files on WebDAV shares.
I have just found this list of variables:
https://help.ubuntu.com/community/NautilusScriptsHowto
The one I was looking for is $NAUTILUS_SCRIPT_SELECTED_URIS, it works on WebDAV too, returning for instance dav://admin#localhost:8080/alfresco/webdav/User%20Homes/leo/test.txt
Nautilus' $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS is only for LOCAL (mounted) files, and by design is blank for remote files, like $1, $2...
For REMOTE files, like WebDAV, or Samba network shares, FTP servers, (or any other location where $NAUTILUS_SCRIPT_CURRENT_URI is not like file://...), use $NAUTILUS_SCRIPT_SELECTED_URIS

Configuring "Web application URL" for team use

So, I'm trying to take advantage of 'Path Variables' (or Linked Resources), in my teams FlashBuilder4 project properties, so that its not such a bear to get a new project out of SVN, and up and running. I'm all done with that, except that I can't figure out what I'm supposed to do for the "Web application URL" .
It doesn't allow me to create a "Path Variable" for http:// type items, only files and folders.
Short of saying that all developers need to configure their servers exactly thus, how can I configure this property so that individual team-members settings don't interfere with other team-members ?
What we do is create Linked Resources to point to a debug directory e.g. project/r11.1/dist in the main project. Everyone has r11.1/dist directory structure within their project. Each person has a local Apache server running, and each person sets up a local Alias in the server for r11.1 that points to whatever location the dist files are stored C:/.../r11.1/.
The SVN only contains the Apache Linked Resource name plus the common folder structure i.e. DISTRIBUTION/r11.1/dist along with the server name i.e. http://localhost.whatever.com/ + {DISTRIBUTION}/r11.1/dist
Does this make any sense in terms of what your after?
Here's what I did to solve the problem. I hate it, but it gets me to where I need to go.
I assigned the "Web Application URL" to the value "https://HOSTS.DASHBOARD.DEV/foo/bar/blah/..."
Then, each of the developers needed, in addition, to create an entry in their HOSTS file, to resolve 'HOSTS.DASHBOARD.DEV' to the proper ip address.
This works (so far), even though I'm less than satisfied with it.

Getting directory listing over http

There is a directory that is being served over the net which I'm interested in monitoring. Its contents are various versions of software that I'm using and I'd like to write a script that I could run which checks what's there, and downloads anything that is newer that what I've already got.
Is there a way, say with wget or something, to get a a directory listing. I've tried using wget on the directory, which gives me html. To avoid having to parse the html document, is there a way of retrieving a simple listing like ls would give?
I just figured out a way to do it:
$ wget --spider -r --no-parent http://some.served.dir.ca/
It's quite verbose, so you need to pipe through grep a couple of times depending on what you're after, but the information is all there. It looks like it prints to stderr, so append 2>&1 to let grep at it. I grepped for "\.tar\.gz" to find all of the tarballs the site had to offer.
Note that wget writes temporary files in the working directory, and doesn't clean up its temporary directories. If this is a problem, you can change to a temporary directory:
$ (cd /tmp && wget --spider -r --no-parent http://some.served.dir.ca/)
What you are asking for best served using FTP, not HTTP.
HTTP has no concept of directory listings, FTP does.
Most HTTP servers do not allow access to directory listings, and those that do are doing so as a feature of the server, not the HTTP protocol. For those HTTP servers, they are deciding to generate and send an HTML page for human consumption, not machine consumption. You have no control over that, and would have no choice but to parse the HTML.
FTP is designed for machine consumption, more so with the introduction of the MLST and MLSD commands that replace the ambiguous LIST command.
The following is not recursive, but it worked for me:
$ curl -s https://www.kernel.org/pub/software/scm/git/
The output is HTML and is written to stdout. Unlike with wget, there is nothing written to disk.
-s (--silent) is relevant when piping the output, especially within a script that must not be noisy.
Whenever possible, remember not to use ftp or http instead of https.
If it's being served by http then there's no way to get a simple directory listing. The listing you see when you browse there, which is the one wget is retrieving, is generated by the web server as an HTML page. All you can do is parse that page and extract the information.
AFAIK, there is no way to get a directory listing like that for security purposes. It is rather lucky that your target directory has the HTML listing because it does allow you to parse it and discover new downloads.
You can use IDM (internet download manager)
It has a utility named "IDM SITE GRABBER" input the http/https URLs and it will download all files and folders from http/https protocol for you.
elinks does a halfway decent job of this. Just elinks <URL> to interact with a directory tree through the terminal.
You can also dump the content to the terminal. In that case, you may want flags like --no-references and --no-numbering.

How to usually .htaccess file when it is hidden in ftp

I usually cannot see .htaccess file because it is hidden, when I login to remote servers with ftp access.
Since I don't have shell access, I usually perform the following steps to edit the file:
I change the settings on my mac (from terminal) to see invisible files
I open .htaccess file on a standard drupal installation and I edit it
I upload it to the remote server and I overwrite the existent one
I disable hidden files on my mac
I was wondering if there is a faster solution
thanks
I often have a separate file in my Drupal root called production.htaccess or something along those lines. Not only does this expose the file in Finder without revealing every single .DS_Store on my system, it also allows me to set separate .htaccess directives for different environments. Then, I just rename production.htaccess to .htaccess after I upload it to the server.
More often than not, the two .htaccess files are identical, but even in that case, I still use this method for the sake of convenience.
The FTP application should have the option to show you hidden files; normally, that is an option available on FTP client applications for Mac OS X.

Resources