Question Locked

Problem Running FTP Script ScheduledTask

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello, all.

I am having a problem getting a command line FTP script to work in a Scheduled Task on a WK3 server. The command works fine when run from the command prompt (when logged in as me [MYDOMAIN\bobr]). However, when it is run as a scheduled task (MYDOMAIN\svc_account_FTP), the status/log shows that the task successfully ran (code 0x2) even though the results do not actually occur.

The command should result in two deliverables: 1) A file (iweb.access.MMDDYY.gz) successfully FTPed from www.iweb.mycompany.com and placed into H:\MaxData\bobtest; and 2) An FTP log file created (iweb_get_yesterday_ftp.log) from the FTP session and placed into H:\MaxData\bobtest.

When this is run at the command line using the following commands, it works successfully:

Start - Run - CMD
C:\>H:
H:\>cd MaxData\bobtest
H:\MaxData\bobtest>ftp -s:FTP_Test_iWeb.txt www.iweb.mycompany.com > iweb_get_yesterday_ftp.log

Here's the contents of the task command and script file:
C:\WINDOWS\system32\ftp.exe -s:FTP_Test_iWeb.txt www.iweb.mycompany.com >
iweb_get_yesterday_ftp.log

myuser
mypswd
cd /usr/webstats/logs/tmp
bin
prompt
mget *
quit

Start in:
H:\MaxData\bobtest

Run as:
MYDOMAIN\svc_account_FTP

Among the things I tried were giving the "run as" account Modify perms on
H:\>MaxData\bobtest; and also by running the task as an administrator. I've also performed an all-drive search for each of the expected filenames, but no results were found.

"MKP FTP iWeb.job" (ftp)
Started 10/30/2007 1:10:46 PM
"MKP FTP iWeb.job" (ftp)
Finished 10/30/2007 1:10:46 PM
Result: The task completed with an exit code of (2).

Can you help me solve this mystery?

TIA,

Bob

10 replies

by retro77

Anything in the scheduled task log? Just for testing, make that service account a local admin on the server you are running the task from. I think the account needs at least Log on Locally and maybe some NTFS permissions to write that log file.

You can see in the task manager if the service account is executing the batch file.

Also, where does that H: go to? Is that a mapped drive? If it is, you'll have to map the drive in the batch file.

edit: sorry I see your scheduled task log there.

by webguybob

Retro,

Thanks for the reply. Unfortunately, it didn't work when a local admin's account was used in the "run as".

FYI ... We created a special service account in the domain, just for FTPing purposes, and gave that account MODIFY perms to the "start in" folder. The Everyone account can traverse all the way down to that folder. Still no luck.

Next ideas???

Thx,

Bob

by lowlands

try to open a cmd windows as the svc_account_FTP and run through your FTP script. Does that work?
runas /user:MYDOMAIN\svc_account_FTP cmd

It'll ask for your password, once successfully logged in, try the ftp commands from your file.

by webguybob

Lowlands,

The behavior was the same as when I opened CMD as myself and issued commands. Success. See next post for my solution.

Thx,

Bob

by webguybob

Thanks to all who replied. I finally got my (an) answer, but it was through a colleague who had a similar problem once...

Answer:
Use a batch file containing the executable string instead of putting the string in the scheduled task interface. Let the batch file call the FTP script:

Task Executable:
H:\MaxData\bobtest\CallFTPScript.bat

Batch File:

ftp -s:FTP_Test_iWeb.txt www.iweb.mycompany.com > iweb_get_yesterday_ftp.log

Script File:

myuser
mypswd
cd /usr/webstats/logs/tmp
bin
prompt
mget *
quit

The Problem (I think):
It seems that Scheduler does not correctly inerpret the precedence/order of the string. Although a successful return code is returned/logged, meaning that it somehow correctly found and executed ftp.exe, no file transer or FTP log creation occured. Odd.

I hope this helps somebody else.

Cheers,

Bob

by retro77

I thought that you were calling the FTP.exe from a batch file.

Also it is able to find ftp.exe because the location of it is in the path statement variable.

So now it sounds like you just have to get that log to read in correctly.

by webguybob

Retro,

Actually, after putting the FTP command string in the batch file and letting the batch file call the FTP script, it ALL worked. :-)

Rgds,

Bob

This discussion is closed to new replies.