Skip to content

Instantly share code, notes, and snippets.

@ctlaltlaltc
Created March 28, 2026 09:26
Show Gist options
  • Select an option

  • Save ctlaltlaltc/930aedb331caadd7fc1bffea74003a0a to your computer and use it in GitHub Desktop.

Select an option

Save ctlaltlaltc/930aedb331caadd7fc1bffea74003a0a to your computer and use it in GitHub Desktop.
execd pty websocket test
user@ubuntu0001:~/code/github/OpenSandbox/components/execd$ ./bin/execd -access-token dev --log-level 7
=====================================================
OpenSandbox Execd
-----------------------------------------------------
Version : csharp/code-interpreter/v0.1.0-12-g9beee69-dirty
Git Commit : 9beee6977b32e7c35860838aff53457ca0ed541f
Build Time : 2026-03-28T09:00:11Z
Go Version : go1.26.1
Platform : linux/amd64
=====================================================
{"level":"info","ts":"2026-03-28T17:03:37.708+0800","msg":"Jupyter server host is: "}
{"level":"info","ts":"2026-03-28T17:03:37.708+0800","msg":"Jupyter server token is: "}
{"level":"info","ts":"2026-03-28T17:03:37.708+0800","msg":"execd listening on :44772"}
{"level":"info","ts":"2026-03-28T17:03:57.561+0800","msg":"Requested: POST - /pty"}
{"level":"info","ts":"2026-03-28T17:03:57.562+0800","msg":"created pty session bb16de36-c254-4410-aebe-eeb757179653"}
{"level":"info","ts":"2026-03-28T17:04:28.912+0800","msg":"Requested: GET - /pty/bb16de36-c254-4410-aebe-eeb757179653"}
{"level":"info","ts":"2026-03-28T17:07:02.974+0800","msg":"Requested: GET - /pty/bb16de36-c254-4410-aebe-eeb757179653/ws"}
{"level":"info","ts":"2026-03-28T17:07:29.439+0800","msg":"Requested: GET - /pty/bb16de36-c254-4410-aebe-eeb757179653/ws?pty=0"}
{"level":"info","ts":"2026-03-28T17:07:47.727+0800","msg":"Requested: GET - /pty/bb16de36-c254-4410-aebe-eeb757179653/ws?since=0"}
{"level":"info","ts":"2026-03-28T17:08:07.103+0800","msg":"Requested: DELETE - /pty/bb16de36-c254-4410-aebe-eeb757179653"}
{"level":"info","ts":"2026-03-28T17:08:07.104+0800","msg":"deleted pty session bb16de36-c254-4410-aebe-eeb757179653"}
user@ubuntu0001:~$ curl -i -H "Content-Type: application/json" -H "X-EXECD-ACCESS-TOKEN: dev" -X POST "http://localhost:44772/pty" -d '{
"cwd": "/tmp"
}
'
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
Date: Sat, 28 Mar 2026 09:03:57 GMT
Content-Length: 53
{"session_id":"bb16de36-c254-4410-aebe-eeb757179653"}
user@ubuntu0001:~$ curl -i -H "X-EXECD-ACCESS-TOKEN: dev" -X GET "http://localhost:44772/pty/bb16de36-c254-4410-aebe-eeb757179653"
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sat, 28 Mar 2026 09:04:28 GMT
Content-Length: 87
{"session_id":"bb16de36-c254-4410-aebe-eeb757179653","running":false,"output_off": 0}
user@ubuntu0001:~$ wscat -H "X-EXECD-ACCESS-TOKEN: dev" -c "ws://localhost:44772/pty/bb16de36-c254-4410-aebe-eeb757179653/ws"
Connected (press CTRL+C to quit)
----
< {"type":"connected","session_id":"e7c49aea-13bb-48cc-8c7d-1f65d768bcc0","mode":"pty"}
<
< bash-5.2$
> {"type":"stdin","data":"ls -la\n"}
< ls -la
< 总计 1224
< drwxrwxrwt 51 root root 36864 3月 28 17:15 .
drwxr-xr-x 25 root root 4096 12月 22 14:02 ..
drwxrwxr-x 2 sxf sxf 4096 3月 28 13:31 08b54cb9da429a21ec768249b70195bd
drwxrwxr-x 2 sxf sxf 4096 3月 28 13:31 0b230085cb310f51a73a364f0a169c27
-rwxrwxr-x 1 sxf sxf 0 3月 28 11:37 0bee7b3eceea412a97e5af2240b06a13.stderr
-rwxrwxr-x 1 sxf sxf 7 3月 28 11:37 0bee7b3eceea412a97e5af2240b06a13.stdout
-rwxrwxr-x 1 sxf sxf 12 3月 28 11:42 0f76da50616349069485fe94c069a476.output
drwxrwxr-x 2 sxf sxf 4096 3月 28 15:50 155b2d11646ed777e393790cfcf219f4
<
< bash-5.2$
> sxf@ubuntu0001:~$
user@ubuntu0001:~wscat -H "X-EXECD-ACCESS-TOKEN: dev" -c "ws://localhost:44772/pty/bb16de36-c254-4410-aebe-eeb757179653/ws?pty=0"
Connected (press CTRL+C to quit)
< bash-5.2$
< {"type":"connected","session_id":"bb16de36-c254-4410-aebe-eeb757179653","mode":"pty"}
user@ubuntu0001:~wscat -H "X-EXECD-ACCESS-TOKEN: dev" -c "ws://localhost:44772/pty/bb16de36-c254-4410-aebe-eeb757179653/ws?since=0"
Connected (press CTRL+C to quit)
< bash-5.2$
< {"type":"connected","session_id":"bb16de36-c254-4410-aebe-eeb757179653","mode":"pty"}
user@ubuntu0001:~$ curl -i -H "X-EXECD-ACCESS-TOKEN: dev" -X DELETE "http://localhost:44772/pty/bb16de36-c254-4410-aebe-eeb757179653"
HTTP/1.1 200 OK
Date: Sat, 28 Mar 2026 09:08:07 GMT
Content-Length: 0
user@ubuntu0001:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment