Search code examples
perlsvkgetpwuid

SVK synk and scheduled task


I'm trying to automate a SVK sync process.
After configuring SVK mirrors, I wrote a batch file with the following

svk sync -a >> svk.log &2>1

then I add a Windows Scheduled task running under my administrative account.

in svk.log I read

The getpwuid function is unimplemented at C:\Programmi\svk\bin\svk line 142.

Any hint?

p.s. I'm able to run svn sync -a from the command line (same user)


Solution

  • When I posted my question, I did not know that

    1. under Windows Scheduler the HOMEDRIVE and HOMEPATH aren't initialized (http://tinyurl.com/9zxbrg8)
    2. The getpwuid function is not available in Windows ports of Perl (http://tinyurl.com/d56a2mv)

    Having the above, I modified /bin/svk file by changing

    $ENV{HOME} ||= (
        $ENV{HOMEDRIVE} ? catdir(@ENV{qw( HOMEDRIVE HOMEPATH )}) : ''
    ) || (getpwuid($<))[7];
    $ENV{USER} ||= (
        (defined &Win32::LoginName) ? Win32::LoginName() : ''
    ) || $ENV{USERNAME} || (getpwuid($<))[0];
    

    in

    $ENV{HOME} ||= (
        $ENV{HOMEDRIVE} ? catdir(@ENV{qw( HOMEDRIVE HOMEPATH )}) : 
                          ($ENV{USERPROFILE} ? $ENV{USERPROFILE} : '')
    );
    $ENV{USER} ||= (
        (defined &Win32::LoginName) ? Win32::LoginName() : ''
    ) || $ENV{USERNAME};
    

    and now I'm able to run my batch calling svk as a Windows scheduled task