Solved

Is it possible to have a batch file or script copy files to an HTTP location?

Posted on 2011-09-29
10
393 Views
Last Modified: 2012-05-12
I am creating a web mapping application for a client and would like to create a seamless update process.  Would it be possible to write a batch file or script to copy files to/from "http://website/update_folder" to "c:/some_folder"?  If so please provide an example.

Thanks
0
Comment
Question by:GreyHippo
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 6

Expert Comment

by:Faisal Khan
Comment Utility
did you try using cuteftp?
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 250 total points
Comment Utility
From is easy enough ... wget.exe will do that for you:

http://gnuwin32.sourceforge.net/packages/wget.htm
Then it is effectively:

cd /d c:\somefolder
wget "http://whatever"

As to uploading... you need to probably be using FTP to the server.  Do you have such aaccess?

I haev some examples of scripts for that here:

http://scripts.dragon-it.co.uk/links/batch-ftp-scripting

I prefer this method (it is all in one .cmd batch file) but there are several others on the scripts page.

@echo off
(echo open 110.110.110.110
echo user username
echo password
echo cd /destination/path
echo bin
echo put "C:\Users\Public\ServerDataBackup\FILE.MDBv1.zip"
echo quit
) | ftp -n -i




0
 
LVL 2

Expert Comment

by:junkymail1
Comment Utility
Currently batch files don't support http requests.  I did do something like you are asking for with the wget program (open source).  It is a popular program and will accomplish what you are looking for in a batch file.

Get it here:
http://gnuwin32.sourceforge.net/packages/wget.htm

Here is an example::
wget -nc -r -o "C:\temp\wget_erros.log" -P "C:\POG IMAGES" https://www.xythosondemand.com/home/SMSB/Shared/

Reference site for further information:
http://www.gnu.org/software/wget/manual/wget.html
0
 
LVL 9

Expert Comment

by:Lester_Clayton
Comment Utility
If you've published the update_folder via webdav, the you can create a script which maps a drive to the URL, and then does the necessary copying.

Here's a simple batch file how to do it:

@echo off
net use t: https://Removed.Removed.no\webdav /persistent:no /user:domain\username Pa$$w0rd
copy c:\console.txt t:
net use t: /delete

Open in new window


Here is it in action:

Webdav Result
NOTE: the URL has been obfuscated for security reasons.

Additional Note: Webdav must be HTTPS in order to accept Windows authentication.  The HTTPS certificate may be internal as long as the workstation connecting to it trusts the signer.  

There are many good guides on the net for publishing a webdav folder, if you want to go down this route.
0
 
LVL 6

Expert Comment

by:Faisal Khan
Comment Utility
you can start with this quick scrip and keep building it.
http://www.c3scripts.com/tutorials/msdos/ftp.html
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 11

Expert Comment

by:paultomasi
Comment Utility
Yep, easy peasy!...

Here's an example. Just sudstitute your own values for those inside '<...>'...


@ECHO OFF

 >script.ftp ECHO <your username>
>>script.ftp ECHO <your password>
>>script.ftp ECHO LCD <"c:\some folder">
>>script.ftp ECHO CD <"update folder">
>>script.ftp ECHO MGET <your filespec>
>>script.ftp ECHO BYE

FTP -s:script.ftp <ftp.your web address>

DEL script.ftp

Open in new window

0
 
LVL 11

Expert Comment

by:paultomasi
Comment Utility
Wow!! Beaten to the post once again!

Thought I had this one in the bag. Should have refreshed my browser before posting...
0
 

Author Closing Comment

by:GreyHippo
Comment Utility
Thanks.  I didn't know about ftp.exe.
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
Glad to help there!

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
Comment Utility
Only thing to watch with ftp.exe is it will only work directly, not through proxy servers and also won't do somethng called "passive mode".  This means it will not work through some sorts of NAT routers to the internet, but will be fine with some, and works on an internal LAN ok.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now