Waldo Pepper;683477 Wrote: 
> The clock on my SB Touch can drift upto 5 mins a week. I have forgot
> most of the obscure Linux commands but since I use my PC most nights, I
> SSH in using Putty on Windows and correct the time manually using "date
> mmddhhmm.ss".
> 
> Lazy, I know.

This has rewoken my old C programming days and I have written a C prog
that can generate a file containing the correct time from my PC (which
is NTP synched and the Touch does not appear to support NTPDate),
converts it to the "date" format required by Linux and ssh the file
into the Touch to automatically correct the time on the Touch when my
PC boots (which is every day). Not keen to post an .exe because of
peoples worry, but happy to show the source and the batch using Plink. 


The batch is:
logitime.exe
plink.exe -ssh -pw <password> -noagent -m commands.txt root@<Touch IP
address> 

The source is:

#include <stdio.h>    
#include <stdlib.h>
#include <time.h>    
#include <io.h>
FILE *commands;



void main (void)
{          
char tim[9];
char dat[9];   
char output[20];

_strdate(dat);
_strtime(tim);

if ((commands=fopen("commands.txt", "w")) == NULL)
{
printf("\n\rError: Could not open output file");
fclose(commands);
exit(-1);
}

sprintf(output,"date
%c%c%c%c%c%c%c%c.%c%c\n\r",dat[0],dat[1],dat[3],dat[4],tim[0],tim[1],tim[3],tim[4],tim[6],tim[7]);
printf("\n\r%s",output);
fprintf(commands,"%s",output);

sprintf(output,"exit"); 
printf("\n\r%s",output);      
fprintf(commands,"%s",output);


fclose(commands);
}                       

Run the batch and it automatically takes DOS time, converts it to Linux
Date and SSH's it into your touch. Make it happen when your PC boots and
you're sorted.

WTP

PM me if you need help.


-- 
Waldo Pepper
------------------------------------------------------------------------
Waldo Pepper's Profile: http://forums.slimdevices.com/member.php?userid=39029
View this thread: http://forums.slimdevices.com/showthread.php?t=92804

_______________________________________________
Touch mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/touch

Reply via email to