I have Cygwin installed on my Windows 7 64 bit PC and I often download large files using wget. wget, however, saves all files with permissions that forbid me from executing the files when they're Windows executable files (.exe or .msi). Is there any way for me to set the permissions such that I can execute these files automatically? Can I also change the default directory to which they're saved? Presently they are saved to the cygwin folder C:\cygwin64\home\Brenton
and I'd like to save them to C:\Users\Brenton\Downloads
.
For clarity's sake I know how to move these files to my desired directory manually after they're saved (e.g., using:
mv filename C:\Users\Brenton\Downloads
where filename is the file name that needs to be transferred) and I know how to change permissions manually via:
chmod 755 filename
but what I want is an automatic way so that all files downloaded via wget from henceforth would be downloaded to my preferred directory with my preferred permissions.
Best Answer
Destination directory
You can use the
-P prefix
/--directory-prefix=prefix
option to directwget
to save to a certain directory.Example to save a single file to your download directory:
File permissions
On my system,
umask
is set to0022
so when I usewget
to download files to my Cygwin home directory, the files have-rw-r--r--
permissions – as expected.However, if I download to my Windows
Downloads
directory, the executable permissions are set. I’m not sure why but I suspect that somehow the permissions are being by influenced by NTFS ACLs. This behaviour may also work to your favour on your system. If it does, you could use a simple shell alias such as:Suggested shell script / function
If you still have to change permissions, you could use the following code as the basis for a shell script or function (called something like
wget-exe
):