Curl download zip extract large xml file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Curl download zip extract large xml file
# 1  
Old 05-03-2013
Curl download zip extract large xml file

Hi i have a php script that works 100% however i don't want this to run on php because of server limits etc. Ideally if i could convert this simple php script to a shell script i can set it up to run on a cron. My mac server has curl on it. So i am assuming i should be using this to download the file. Here's the php code

PHP Code:
    $url  'http://xmlfeed.laterooms.com/staticdata/hotels_standard.zip';
    
$path '../../data/hotels_standard.zip';
 
    
$fp fopen($path'w');
 
    
$ch curl_init($url);
    
curl_setopt($chCURLOPT_FILE$fp);
 
    
$data curl_exec($ch);
 
    
curl_close($ch);
    
fclose($fp);
    
    
$zip = new ZipArchive;
    if (
$zip->open('../../data/hotels_standard.zip') === TRUE)
    {
          
$zip->extractTo('../../data/');
          
$zip->close();
          
    }
    else
    {
          echo 
'extration of file failed :(<br />';
    } 
Can someone help me turn this in to a shell script.
# 2  
Old 05-03-2013
I think wget and unzip are the only commands you really need for this to work
# 3  
Old 05-03-2013
You can use following curl & unzip commands in your shell script -

Code:
curl -O HTTP_URL_FOR_ZIP_FILE
unzip ZIP_FILE_NAME -d EXTRACT_DIR


Last edited by BhushanPathak; 05-03-2013 at 08:19 AM.. Reason: specified extraction directory for unzip command
This User Gave Thanks to BhushanPathak For This Post:
# 4  
Old 05-03-2013
Oh thats easy thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Curl , download file with user:pass in bash script

Hello, My question is about curl command. (ubuntu14.04) In terminal, I am able to download my mainfile with: curl -u user1:pass1 http://11.22.33.44/******* When I convert it into bash script like this: #!/bin/bash cd /root/scripts computer_ip=11.22.33.44 curl -u $1:$2... (8 Replies)
Discussion started by: baris35
8 Replies

2. Shell Programming and Scripting

Curl to download file from subdivx.com after following location without knowing the file name/extens

This question could be specific to the site subdivx.com In the past, I've been able to download a file following location using cURL but there is something about subdivx.com that's different and can't figure out how to get it to work. I tried the following directly in the terminal with no... (5 Replies)
Discussion started by: MoonD
5 Replies

3. Shell Programming and Scripting

Curl parallel download file list

Hello guys, first post sorry if I did some mess here =) Using Ubuntu 14.04lts 64bits server version. I have a list (url.list) with only URLs to download, one per line, that looks like this: http://domain.com/teste.php?a=2&b=3&name=1 http://domain.com/teste.php?a=2&b=3&name=2 ...... (6 Replies)
Discussion started by: tonispa
6 Replies

4. Shell Programming and Scripting

Curl command to download multiple files with a file prefix

I am using the below curl command to download a single file from client server and it is working as expected curl --ftp-ssl -k -u ${USER}:${PASSWD} ftp://${HOST}:${PORT}/path/to/${FILE} --output ${DEST}/${FILE} let say the client has 3 files hellofile.101, hellofile.102, hellofile.103 and I... (3 Replies)
Discussion started by: r@v!7*7@
3 Replies

5. UNIX for Dummies Questions & Answers

Extract .zip file without using unzip,tar

Hi, Need to extract a file containing multiple .txt files without using tar/unzip as they are not available (1 Reply)
Discussion started by: santoshdrkr
1 Replies

6. Shell Programming and Scripting

How to download a large zip file from a website?

Hi, I am trying to write a shell script which will download a file from a website say <http://xyz.com/file1.zip>. The file is in .zip format and its size is huge, normally more than 20MB. I searched and found that simplae way to do it is using wget -O /home/pat <website address> ... (1 Reply)
Discussion started by: pat_pramod
1 Replies

7. Shell Programming and Scripting

Use curl to send a static xml file using url encoding to a web page using pos

Hi I am try to use curl to send a static xml file using url encoding to a web page using post. This has to go through a particular port on our firewall as well. This is my first exposure to curl and am not having much success, so any help you can supply, or point me in the right direction would be... (1 Reply)
Discussion started by: Paul Walker
1 Replies

8. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

9. Shell Programming and Scripting

How to download file without curl and wget

Hi I need a Shell script that will download a zip file every second from a http server but i can't use neither curl nor wget. Can anyone will help me go about this task ??? Thanks!! (1 Reply)
Discussion started by: rubber08
1 Replies

10. Shell Programming and Scripting

parsing large CDR XML file

Dear Freind in the file attached how parse the data to be like a normal table :D (3 Replies)
Discussion started by: saifsafaa
3 Replies
Login or Register to Ask a Question