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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
marktorregrossa
Posts: 6
Joined: 2011-12-28T20:23:59-07:00
Authentication code: 8675308

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
Last edited by fmw42 on 2011-12-28T21:26:18-07:00, edited 2 times in total.
marktorregrossa
Posts: 6
Joined: 2011-12-28T20:23:59-07:00
Authentication code: 8675308

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

Post 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.
marktorregrossa
Posts: 6
Joined: 2011-12-28T20:23:59-07:00
Authentication code: 8675308

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

Post 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.
Post Reply