Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 01-27-2010, 12:41 PM   #1
LQ Newbie
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
running wget from .bat using cygwin - syntax question


This is my first post, and I am about as green as they come with regards to UNIX, so any help or direction would be appreciated. I've searched this forum, and spent a few hours on Google, but I haven't been able to find anything that
1) applies to my problem
2) I can understand

In a nutshell I'm trying to use wget on a Windows Vista box to download numerical weather model outputs. I was scared off trying to build wget in Windows by the README warning that wget 1.12 is severly broken in Windows, so I have installed cygwin as a workaround.

I have tested every part of this scrip individually, but either I'm not getting my syntax right (likely) or this isn't possible (unlikely I hope).
The .bat file will be run as a sched. task, and clear out the previous model runs files from the directory before downloadin the new ones.

The script is below - how do I pass the change directory command and the commands for wget through a .bat script to run in cygwin?
I have seen references to cygpath, and I tried many different combinations, but I'm in the dark.
These are the commands that I want to pass to cygwin from the .bat file:

cd H:\GRIB
wget -nd -nc -i GEM15_files.txt -P H:\GRIB\GRIBtest -B

Thanks in advance,

path %path%;c:\cygwin
echo y | del H:\GRIB\GRIBtest
cd H:\GRIB
start c:\cygwin\cygwin.bat -|wget -nd -nc -i GEM15_files.txt -P H:\GRIB\GRIBtest -B
Old 01-27-2010, 03:10 PM   #2
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
cd /cygdrive/h/GRIB
Old 01-28-2010, 02:13 PM   #3
LQ Newbie
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks AlucardZero,

I tried that, and it works fine if I enter it directly into the cygwin prompt, but the commands still won't pass from the .bat file to the cygwin prompt. The script executes, and gets to the point where the cygwin prompt $ shows in the command line window, but it hangs there. The script that I'm working with is below in it's entirety. Is it a simple case of surrounding the UNIX commands with "", or preceding them with a $, or some combination thereof?
I have tried several combinations, but again, the script will run if I enter the two UNIX commands into cygwin directly, but the .bat file won't pass them to cygwin to execute.

Thanks again for the help,

path %path%;c:\cygwin
echo y | del H:\GRIB\GRIBtest
cd c:\cygwin
cd cygdrive/h/GRIB
wget -nd -nc -i GEM15_00Z_files.txt -P H:\GRIB\GRIBtest -B
if errorlevel 0 goto okay
echo Script failed with errorlevel = %errorlevel%
Old 02-02-2010, 02:58 PM   #4
LQ Newbie
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
I figured it out. Here's what I did, in case anyone else is trying to do the same thing.

First, enter the 'wget' program into the PATH environment variable. The .exe should be in the cygwin\bin folder - C:\cygwin\bin\wget.exe
Then, create a .sh file with the desired commands for wget ( This shell script has to be in the cygwin/bin folder.
The cygdrive operator is needed within the wget commands to specify the directory to save the downloaded files to, but for whatever reason, I was able to read a file containing a list of URLs without the cygdrive operater from the same wget command...not sure why that is, but it works.

To run the process from a Windows command prompt, enter:
cd cygwin\bin
bash -li

It was this link that pointed me in the right direction - might prove useful for others.

This probably isn't the best way to do it, so if anyone has any suggestions that would streamline it, feel free to chime in.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Xming or cygwin/X on a PC with two networks PeterSmithson Linux - Software 0 12-19-2008 06:52 AM
Compiling/Running Java in Cygwin IsharaComix Linux - Software 0 09-29-2008 09:05 AM
Cygwin X logout, keep programs running poeta_boy Linux - Newbie 3 03-31-2006 03:52 PM
Wget - syntax question satimis Linux - Software 3 09-11-2004 04:29 AM
Question about jigdo-lite.bat is it possible to use knoppix with it for first CD? maximalred Debian 3 06-11-2004 11:47 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration