Page 1 of 1

How do I run this windows cmd file on a linux server?

Posted: 2011-12-28T20:38:41-07:00
by marktorregrossa
I have a simple cmd file that works on a windows machine. I want to do the same thing in a crontab on a web server running linux. I can log onto my server through SSH and type the same commands and it works. But how do i make those commands into a file that I can tell a crontab to run. I tried a php script but couldn't get it to work.

Here's the cmd batch file. It goes to a webpage that is a gif image, resizes it, and saves it as natradar.gif

convert http://radar.weather.gov/ridge/Conus/Ra ... latest.gif -resize 400 natradar.gif

thanks for any help.

Re: How do I run this windows cmd file on a linux server?

Posted: 2011-12-28T21:16:20-07:00
by fmw42
marktorregrossa wrote:I have a simple cmd file that works on a windows machine. I want to do the same thing in a crontab on a web server running linux. I can log onto my server through SSH and type the same commands and it works. But how do i make those commands into a file that I can tell a crontab to run. I tried a php script but couldn't get it to work.

Here's the cmd batch file. It goes to a webpage that is a gif image, resizes it, and saves it as natradar.gif

convert http://radar.weather.gov/ridge/Conus/Ra ... latest.gif -resize 400 natradar.gif

thanks for any help.

There is no reason that I can see that your command does not work in Unix, at least in command line mode. When you try to run that from a server or interface that to some other program, like crontab (I don't know what that is), there may be objections/permission issues to using http to access a web page. Or perhaps it is something else in your Batch file, which you don't show.

First thing is to see if your command works in command line mode in a terminal window. It works perfectly fine for me in IM 6.7.4.2. Q16 Mac OSX Snow Leopard.

If you want the command in a script on unix, you can use a bash shell script. Open a text editor and type the following and then save the file as whatever name you want with .sh as suffix.

#!/bin/bash
fullpath2im/convert http://radar.weather.gov/ridge/Conus/Ra ... latest.gif -resize 400 natradar.gif


The above two lines should be all you need. You may need the full path to where IM resides. Depending upon your system and chrontab you may be able to leave it off. If you don't know where it is located, then you can find that by typing in your terminal:

which convert

or

type convert



Then call the script name from your chrontab or whatever using the full path to the script using whatever launching function is needed.

I really don't know anything about chrontab, so some one else will have to contribute here about using it to call a shell script.

Re: How do I run this windows cmd file on a linux server?

Posted: 2011-12-28T21:20:08-07:00
by marktorregrossa
it does run in a shell, but I'm trying to have it run every 10 minutes. That's why I'm trying to turn it into a file that I can set up in a crontab. A crontab is like scheduled tasks only run from my linux web server.

Re: How do I run this windows cmd file on a linux server?

Posted: 2011-12-28T21:29:27-07:00
by marktorregrossa
fmw42- Maybe this is Fred! Thanks for the bash code. I will give that a try. Looks like what I'm looking for.
thanks much.