Can't curl then unzip zip file - bash

I'm just trying to curl this zip file, then unzip it
curl -sS https://www.kaggle.com/c/word2vec-nlp-tutorial/download/labeledTrainData.tsv.zip > labeledTrainData.tsv.zip
unzip labeledTrainData.tsv.zip labeledTrainData.tsv
but I keep getting the error;
Archive: labeledTrainData.tsv.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
I'm using the same syntax as found in this response, I think. Is there something wrong with the file I'm downloading? I feel like I'm making a noob mistake. I run these two commands in a shell script

I am able to replicate your error. This sort of error generally indicates one of two things:
The file was not packaged properly
You aren't downloading what you think you're downloading.
In this case, your problem is the latter. It looks like you're downloading the file from the wrong URL. I'm seeing this when I open up the alleged zip file for reading:
<html><head><title>Object moved</title></head><body>
<h2>Object moved to here.</h2>
</body></html>
Long story short, you need to download from the alternate URL specified above. Additionally, Kaggle usually requires login credentials when downloading, so you'll need to specify your username/password as well.

Related

How to download file from jenkins artifact using wget where file name version will be changing

Using below code i am able to download srww_1.2.3.4.dmg file but file version number will change daily so i cannot hardcode filename.
How to download file without hardcoding file name.
wget "https://test.com/job/testreport/job/${{parameters.test_buildjob}}/lastSuccessfulBuild/artifact/directrs/srww_1.2.3.4.dmg" --no-check-certificate --http-user=$(USERNAME) --http-password=$(PASSWORD) --auth-no-challenge --no-verbose -O srww_1.2.3.4.dmg
Please help me.
I suggest you take a look at the ReST API of Jenkins:
https://test.com/job/testreport/job/${{parameters.test_buildjob}}/lastSuccessfulBuild/api
Particularly, the XML or JSON form should provide you with the version number built by the job, so you can get the version number first, and then use it when calling to wget.

How do you change the download directory for youtube-dl

I am using youtube-dl for a Discord Music Bot, everything works perfectly until I use the 'play' command. An error occurs "Command raised an exception: DownloadError: ERROR: unable to open for writing: [Errno 13] Permission denied: 'National Anthem of USSR-U06jlgpMtQs.webm.part'" from what I have read (and what the error says) it is because youtube-dl doesn't have permission to download filed to a certain folder. So I'd imagine that an easy solution is to just change the download directory. I can't find anything on how to do it for python, so any help would be greatly appreciated!
Thanks,
Found on github's documentation for it.
Locate youtube-dl's config file from:
Linux/macOS:
System-wide config : /etc/youtube-dl.conf
User-wide config : ~/.config/youtube-dl.conf
Windows:
C:\Users\<username>\youtube-dl.conf
%APPDATA%\youtube-dl\config.txt
If non-existent, you can create it yourself.
Example file contents:
-o A:/path/to/file/%(title)s.%(ext)s
References:
Flag to specify a file path.
Setting up config file.
Spent some time to figure out on Windows 10 and it might help someone in the future.
I've downloaded youtube-dl.exe from the latest build and downloaded by executing, youtube-dl.exe URL, from my home directory. The program says downloaded completed but *** it was not there so I issued the command again, and it says there already exist file ##$#%!##%$. Well, I found out -o option to change the name of the downloaded file and it finally helped me to search for the file and the following location was the default directory.
Go to C:\Users[YOUR USER NAME GOES HERE]\AppData\Local\VirtualStore

cURL makes invalid bencoding when downloading torrents from torcache

The title says it all. I realize that a similar question has been asked at https://askubuntu.com/questions/307566/wget-and-curl-somehow-modifying-bencode-file-when-downloading/310507#310507 but I don't think the same solution works, because I have tried to unzip the file using 7zip, and also Gzip for windows (http://gnuwin32.sourceforge.net/packages/gzip.htm). Both claim the file to be of wrong format. Renaming it's extension to .gz or .zip doesn't help either. The --compressed attribute is no help as well. So, my guess is something's changed on the torcache site. I've tried using the user-agent as well, to no avail.
In a related issue, I guess, when I try downloading from the https site, I recieve "curl: (52) Empty reply from server". Only http works, and that gives me invalid bencoding. When I enter the URL on my browser, the torrent file downloads all by itself.
The command I'm entering is as follows:
curl -O http://torcache.net/torrent/006DDC8C407ACCDAF810BCFF41E77299A373296A.torrent

Update Magento extension using ssh to extract .tgz tar file

I am trying to update a module to a newer version. In the past I have manually uploaded each file carefully into the new directory and overwritten older files using FTP. However I wanted to use SSH to try and do this more easily and without any file permission problems.
I have:
Uploaded the .tgz file to the root folder (/http) on the server
Logged into the server via SSH
Changed the directory to the correct directory
Run the following command: tar -zxvf fishpig_splash.tgz
In the command line I was then given a list of all the files that had been extracted. However if I use FTP to go to any of these files I can see that they are still the older version and have not been overwritten.
I was expecting that the files would extract into the correct directories and overwrite any that already existed. I have tested the extraction by creating a temporary directory and extracting into that and everything worked fine.
Is there another part to this script I need to use to overwrite the files?
Thanks
Glynn
Sorry this was just me being stupid! When extracting the tar file there was a subfolder within it for the extension, I completely missed it. I just went down a level in the file and zipped up the contents only then extracted them at the root and everything worked fine. Thanks for the help though!

FileZilla FTPing unzip problems

I have a bash script that utilises inotify-tools to wait for .zip files to be dropped in a substructure under the root. From there they are unzipped into a another directory.
When I copy the .zip files in with WinSCP the script executes correctly. Copying the .zip files with Filezilla leads to this error however:
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
I've googled this error and the two main issues seem to be an old version of Linux's unzip functionality, which I have a newer version of, and trying to copy files that are > 2gb (this file isn't)
Anyone know the issue here, it seems to me that Linux is trying to unzip the script before it is fully copied to disk? Like I said, only filezilla has this error, I don't get it with winSCP
I believe your main issue is you try to process the ZIP when it is still being transfered. Probably what happens is that as soon as the transfer is initiated WinSCP creates a temporary files to store the transfered data. That event would fire your script before the zip file is complety transfered.
That would explain why you get this error :
End-of-central-directory signature not found. Either this file is not
a zipfile,
So the solution would be to have two folders one for transfer and one for compelete. They should be in the same file system. On transfer complete just move from one folder to another.

Resources