sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    IO.popen behaving strangely within SU

    Scheduled Pinned Locked Moved Developers' Forum
    1 Posts 1 Posters 414 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      draftomatic
      last edited by

      Hi all -

      I am trying to run a subprocess from a shell command using IO.popen (have also tried Kernel#system with identical results), and I'm getting odd behavior. Here's my code:

      curl = "curl "
      curl += "--cookie \"JSESSIONID=#{@sessionid}\" "
      curl += "-H \"Content-type;application/octet-stream\" "
      curl += "-X POST "
      curl += "-o \"#{responseFile}\" "
      curl += "--data-binary \"@#{filename}\" "
      curl += "\"#{url}\""
      
      puts "command; #{curl}"
      
      IO.popen(curl, "r") { |out|
        out.readlines
      }
      # Script never makes it to here
      

      It's a streaming file upload using curl. Curl starts uploading, sends about 100kb, which is received by my server, and suddenly the stream ends ("unexpected end of stream error" on the server-side). Curl keeps running endlessly, sending zero data after that. Since I'm blocking with readlines, SU is forever frozen from then on...

      I have tried this same code in a standalone script as well as running the command directly from a shell, and both work fine.

      Anyone encountered this before? SU doesn't seem to like subprocesses...

      EDIT: I should note this is on OSX.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement