I am writing a scheduler using perl to work in a distributed environment.
Each host will be required to run a server that will execute tasks return
their sucess or failure. I have written pretty much most of the code to
execute the tasks, but it seems the system() function is adding a "?" to the end of any file redirections. For example, if I ask it to run the command ls > /tmp/ls.txt the file /tmp/ls.txt? is created. Similarly if I ask it to run date > date.txt I get date.txt?
Output of uname:
Linux rwc3.richardcrossley.com 2.4.18-14custom #2 Mon Feb 24 08:07:17 GMT
2003 i686 i686 i386 GNU/Linux
Output of perl --version
This is perl, v5.8.0 built for i386-linux-thread-multi (etc...)
I have attached the code for the server. The problem can be recreated using the following telnet session...
telnet localhost 2345
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
Thanks in advance.
Last edited by richardcrossley; 03-10-03 at 04:30.
Telnet will send the RETURN you enter after each line to the server.
But it will be send as DOS Return: cr/lf.
Since your server runs on linux, Perl will strip only the 0x0a/lf with chomp, leaving the 0x0d/cr at the end of the string.
The filesystem converts the 0x0d to a ?.
Either strip off the 0x0d by hand using chop or change the input record separator before chomping like this: