TclCurl and Cookies

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TclCurl and Cookies

  • Creator
    Topic
  • #52000

    Has anyone used TclCurl with browser cookies?

    -- Max Drown (Infor)

Viewing 1 reply thread
  • Author
    Replies
    • #72652
      David Barr
      Participant

        I don’t think I have.  If I need to do that kind of thing, I normally exec a Perl script that uses Mechanize.

      • #72653

        Here is how we did it (skeleton code).

        Code:

        #!/opt/healthvision/cis5.8/integrator/bin/tcl

        package require TclCurl

        # Read in the XML Payload
        set fileName [lindex $argv 0]
        set f [open $fileName r]
        fconfigure $f -translation binary
        set xml [read $f]
        close $f

        set ch [curl::init] ;# Set curlHandle (ch)

        set url http://159.140.46.181/MillenniumMobile/servlet/com.cerner.millenniummobile.documentation.DocumentationServlet?Action=GetFile&Path=html/Login.html
        $ch configure -url $url -cookiefile “” -cookiejar “-” -headervar headers -bodyvar reply; catch {$ch perform} err

        set url http://159.140.46.181/MillenniumMobile/servlet/j_security_check
        $ch configure -url $url -cookiefile “” -cookiejar “-” -post 1 -postfields “j_username=name&j_password=pass” -headervar headers -bodyvar reply; catch {$ch perform} err

        set url http://159.140.46.181/MillenniumMobile/servlet/com.cerner.foundation.code.CodeServlet
        $ch configure -url $url -cookiefile “” -cookiejar “-” -httpheader [list “Content-Type: text/xml”] -postfields $xml -headervar headers -bodyvar reply; catch {$ch perform} err

        catch {$ch cleanup} err

        puts “nnreply: $replynn”

        Fragment:

        Code:

        $ch configure -url $url -cookiefile “” -cookiejar “-” -httpheader [list “Content-Type: text/xml”] -postfields $xml -headervar headers -bodyvar reply; catch {$ch perform} err

        Sample Output:

        Code:

        reply:
        665SuccessStep returned a Success status.
        MaleMALE363

        -- Max Drown (Infor)

    Viewing 1 reply thread
    • The forum ‘Cloverleaf’ is closed to new topics and replies.