LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-27-2010, 11:41 AM   #1
alpinescott
LQ Newbie
 
Registered: Jan 2010
Posts: 3

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


Hello,

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 http://dd.weatheroffice.ec.gc.ca/mod...tion/grib1/00/

Thanks in advance,
Scott

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 http://dd.weatheroffice.ec.gc.ca/mod...tion/grib1/00/
 
Old 01-27-2010, 02:10 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
cd /cygdrive/h/GRIB
 
Old 01-28-2010, 01:13 PM   #3
alpinescott
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,
Scott

path %path%;c:\cygwin
echo y | del H:\GRIB\GRIBtest
cd c:\cygwin
cygwin.bat
cd cygdrive/h/GRIB
wget -nd -nc -i GEM15_00Z_files.txt -P H:\GRIB\GRIBtest -B http://dd.weatheroffice.ec.gc.ca/mod...tion/grib1/00/
if errorlevel 0 goto okay
echo Script failed with errorlevel = %errorlevel%
kay
 
Old 02-02-2010, 01:58 PM   #4
alpinescott
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 (script.sh). 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:
c:
cd cygwin\bin
bash -li script.sh

It was this link that pointed me in the right direction - might prove useful for others.
http://cygwin.com/ml/cygwin/2007-12/msg00506.html

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.

Cheers,
Scott
 
  


Reply



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 05:52 AM
Compiling/Running Java in Cygwin IsharaComix Linux - Software 0 09-29-2008 08:05 AM
Cygwin X logout, keep programs running poeta_boy Linux - Newbie 3 03-31-2006 02:52 PM
Wget - syntax question satimis Linux - Software 3 09-11-2004 03:29 AM
Question about jigdo-lite.bat is it possible to use knoppix with it for first CD? maximalred Debian 3 06-11-2004 10:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:49 PM.

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