X-Spam-Check-By: sourceware.org Message-ID: <43C02075.4050609@cygwin.com> Date: Sat, 07 Jan 2006 15:11:33 -0500 From: "Larry Hall (Cygwin)" Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050929 Thunderbird/1.0.7 Fedora/1.0.7-1.1.fc4 Mnenhy/0.7.3.0 MIME-Version: 1.0 To: "Christian Lanconelli (servizio)" CC: cygwin AT cygwin DOT com Subject: Re: help cron cygwin References: <004601c61338$2d332260$ac01a8c0 AT tanhauser> In-Reply-To: <004601c61338$2d332260$ac01a8c0@tanhauser> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Christian Lanconelli (servizio) wrote: > Hi, > > CRON can run commands wrote in fortran containing the call system() > statement? > this is my program : trasf_DOS.f > It write a DOS batch file that is immediately run by the 'call system > ("copio.bat")' statement- > It WORK WELL in the bash shell (cygwin because I use the DOS commands xcopy) > but can't run as a cron scheduled job. > Both trasf_DOS.exe, and copio.bat, are in the $PATH. > > 1) IT WORKS NORMALLY: > Administrator AT ragas /cygdrive/c/cvi/ICARO/dati > $ ./trasf_DOS.exe > > sab 07/01/2006 > Prima della trasformazione: 7 1 2006 > Dopo la trasformazione: 6 1 6 > === Copio i file lanciando il batch appena creato === > c:\cvi\ICARO\dati>xcopy c:\cvi\ICARO\dati\??060106.* \\pc27\CO2_O3\ /D /F > /Z > C:\cvi\ICARO\dati\DD060106.GAS -> \\pc27\CO2_O3\DD060106.GAS > C:\cvi\ICARO\dati\DD060106.MET -> \\pc27\CO2_O3\DD060106.MET > C:\cvi\ICARO\dati\DD060106.RAD -> \\pc27\CO2_O3\DD060106.RAD > C:\cvi\ICARO\dati\MN060106.DEU -> \\pc27\CO2_O3\MN060106.DEU > C:\cvi\ICARO\dati\MN060106.GAS -> \\pc27\CO2_O3\MN060106.GAS > C:\cvi\ICARO\dati\MN060106.MET -> \\pc27\CO2_O3\MN060106.MET > C:\cvi\ICARO\dati\MN060106.RAD -> \\pc27\CO2_O3\MN060106.RAD > 7 File copiati > > (end of trasf_DOS.exe) > > 2) IT IS IN THE PATH > Administrator AT ragas /cygdrive/c/cvi/ICARO/dati > $ echo $PATH > /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINNT/system32:/cygd > rive > /c/WINNT:/cygdrive/c/VXIPNP/WinNT/Bin:/cygdrive/c/cvi/icaro/dati > > 3) Here are the crontab -l output: > Administrator AT ragas /cygdrive/c/cvi/ICARO/dati > $ crontab -l > 40 * * * * trasf_DOS.exe;echo "tab eseguito alle > $(date)">/home/Administrator/cronlog > > The file "cronlog" is regularly updated. But trasf_DOS appears not work! > > Can you help me? What's my error? It's a common cron misconception that occurs across all platforms on which it runs. The fact that a script runs when logged in but not in cron suggests that it is a path issue. Don't assume the path is right. Don't assume that things cron runs will have exactly the same environment you have on the command line. Write defensively scripts/apps that cron will run. In this case, providing the fully qualified path to your executable and copio.bat when they are invoked should help. Keep in mind as well that Cygwin compiled programs are going to invoke Cygwin's system(), not Windows, and that .bat files aren't going to be interpreted properly by any Cygwin shell. So you'll probably want to invoke a fully qualified "command.com" or "cmd.exe" as part of your system() call, depending on your target platform. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/