HI,all:
    I wrote a file like this: test.c
#include <stdio.h>
#include <stdlib.h>
#include<locale.h>
int main()
{
   FILE *fpipe;
   char *command="cd /data/cdc/document/;/usr/bin/svn  status 73/2788
--config-dir /home/svnroot/.subversion 2>&1";
   char line[256];

 if ( !(fpipe = (FILE*)popen(command,"r")) )
{  // If fpipe is NULL
   perror("Problems with pipe");
   exit(1);
 }

while ( fgets( line, sizeof line, fpipe))
{
  //printf("%s", line);
  puts(line);
}
pclose(fpipe);
}

and I compiled it, run on the OpenSUSE
gcc -o test test.c
./test
This way works fine, There is no errors output, but when I use crontab to
run it,
* * * * * /root/test >> /var/log/test.log 2>&1

The error comes out:
tailf -f /var/log/test.log


svn: Error converting entry in directory '73/2788' to UTF-8

svn: Can't convert string from native encoding to 'UTF-8':

svn: ?\228?\189?\160?\229?\165?\189.txt


The directory contains a  file using chinese character,I have searched
online,most articles said using " export LC_ALL='en_US.utf-8' "  to solve
this problem,I try to add this  code to the file

#include <stdio.h>
#include <stdlib.h>
#include<locale.h>
int main()
{
   FILE *fpipe;
   char *command="cd /data/cdc/document/;/usr/bin/svn  status 73/2788
--config-dir /home/svnroot/.subversion 2>&1";
   char line[256];
   char *b = setlocale(LC_ALL, "en_US.utf-8");
   puts(b);
   b = setlocale(LC_ALL, NULL);
   puts(b);

 if ( !(fpipe = (FILE*)popen(command,"r")) )
{  // If fpipe is NULL
   perror("Problems with pipe");
   exit(1);
 }

while ( fgets( line, sizeof line, fpipe))
{
  //printf("%s", line);
  puts(line);
}
pclose(fpipe);
}

I compile it again, run by the crontab, but it does not  work, the error
still exists. How can I solve this problem?

Reply via email to