This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Script .bat launched before login to Windows

roman_listas optenet wrote:


I've created a script to do some ftp mirroring (by using rsync, through
ssh). The .bat works perfectly if launched from a Windows session
(logged as Administrator). Basically, the .bat is similar to cygwin.bat,
but I pass a .sh script to the last command (the bash statement) so the
sequence is:
- I invoke the .bat script
- this one invokes bash with finally executes .sh script

The .sh script basically launches a rsync -e ssh (client mode) against a
server running sshd. The authentication against ssh is transparently
done by public key authentication.

Well, as I said, this works if launched from a Windows session. Now, I
want to automatize this. For doing so, I've created an "at" entry for
user Administrator, so the .bat script is launched as that user every
day at a given time. Nevertheless, it doesn't work. I've had a look at
this, and the problem seems to be that .bat script lacks the environment
for Administrator, so it doesn't know where to look for the ssh key
necessary for auth. In other words, the .bat is being run without a
Windows session established so it cannot retrieve some data (I think
that's the problem).

My question is: which modifications should I have to do to my .bat
script so it could retrieve the correct environment for Administrator
account? Any idea? I tried to add a "set username=Administrator" to the
.bat script but it seems not to work. I'm quite lost here :-/. Please,

Think about the differences between running this batch file directly and
running it from 'at' (or Cygwin's 'cron' for that matter).  You're
not running it, are you?  Something else is ('at' in your case).  'at'
is a service.  Services are not run as your user.  They are run as
'SYSTEM'.  So you need to make sure that all environment variables and
any Cygwin mount points used are available to the 'SYSTEM' account.  I'd
start with the mount points, since those are easiest to convert if needed
(see 'man mount' or 'mount --help').  The CYGWIN environment variable is
possibly needed to get things going, assuming you have it set in your
environment.  Any others that are needed will depend on what you're

This should be enough to get you going in the right direction.

-- Larry Hall RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746

-- Unsubscribe info: Problem reports: Documentation: FAQ:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]