Task scheduler vs ssh connection in windows2003

411 Views Asked by At

Environment & Task: I have configured the ssh password less authentication(by exchanging public key) between user1 of machine1(2003) and user2 of machine2(HP-UX) machine after words I am using that ssh connection in the perl script to execute the ssh command at machine2.

Issue: When ever i am manually executing the script from machine1 it is not asking any password for user2 of machine2, If i execute the same throught the task shedular of windows2003 it is asking the password of user2 of machine2. can any body help me out in knowing the reason..

Thanks in advance, kishore.

1

There are 1 best solutions below

0
On

This was a nightmare.

I finally figured out that you need to set the HOMEDRIVE and HOMEPATH environment variables. Using the command 'set' to print out the environment variables when running interactive and with task scheduler and comparing the output, these were the only two that were not present with task scheduler and thank God they worked. After setting these, the task scheduler could finally see the known hosts,

If you want to use scp to copy files to the windows machine you will probably come across another delightful problem when running via task scheduler: for some reason scp cannot copy to any old folder, it must be the home folder of the logged in user. Well maybe it's not quite as restrictive as that but I honestly could not be bothered finding out by the time I was done with 6 hours of this nonsense. Anyway, the workaround is to first scp the files to the logged in user's home folder, then move them to the final destination after that.

Here is how my batch file ended up (run from inside the final destination directory):

set HOMEDRIVE=C:
set HOMEPATH=\Documents and Settings\loggedinuser

echo Compressing data files on server...
ssh user@host "cd /foo/bar ; gzip -fc foobar > foobar.gz"

echo Copying files from server...
scp user@host:/foo/bar/foobar.gz "%HOMEPATH%"

move "%HOMEPATH%\foobar.gz" .

I hope this helps some poor soul out there someday.