Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    159

    Unanswered: system function appends "?"

    Hi,

    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
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    START_TASK:ls >/tmp/ls.txt
    SHUTDOWN
    Connection closed by foreign host.


    Thanks in advance.
    Attached Files Attached Files
    Last edited by richardcrossley; 03-10-03 at 04:30.

  2. #2
    Join Date
    Sep 2002
    Location
    Germany, near Aachen
    Posts
    120
    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:

    recv (SCHEDULER, $data_read, $maxlength, 0);
    {
    local $/ = chr(13).chr(10);
    chomp $data_read;
    }

    rgds

  3. #3
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    159
    Many thanks I'll give that a try.

  4. #4
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    159
    $/ = chr(13) . chr(10)

    Works a treat.

    Danke!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •