exec response returning with extra data
See original GitHub issueScenario I’m trying to check if a specific files exists in my pod and assert it on my end using a direct string to string comparison.
Code Snippet
cmd = "[ -f /etc/hosts ] && echo 'True' || echo 'False'"
response = kubernetes_client.connect_post_namespaced_pod_exec(pod, kubernetes_namespace, stderr=True, stdin=True, stdout=True, command=cmd, tty=False)
is_file = response.strip()
print is_file
print [ord(c) for c in is_file]
print len(is_file)
Output
True
[1, 1, 84, 114, 117, 101]
6
Problem Before in kubernetes v1.0.0.b1, I did not have those extra characters in the beginning of my response but with the latest v1.0.0b3 I do. Anyone know why this is the case?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Curl exec returns more than JSON. How do I extract just the ...
I need to get JUST the JSON data from my curl response and I'm not sure the best way to go about it?...
Read more >EXEC CICS WEB RECEIVE (Client) - IBM
Receive an HTTP response for CICS as an HTTP client. ... If the value returned is more than 40 bytes, the data is...
Read more >Execute multiple requests using the Organization service
When false , do not return responses. If set to true and a request does not return a response, because that is its...
Read more >RegExp.prototype.exec() - JavaScript - MDN Web Docs - Mozilla
The exec() method executes a search for a match in a specified string and returns a result array, or null.
Read more >shell_exec - Manual - PHP
shell_exec — Execute command via shell and return the complete output as ... I just added the following lines before shell_exec and the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I remove my last two comments as they were confusing. I like @mrmcmuffinz suggestion and I will send a PR for that. Basically what you see was my failed attempt to provide enough information for the caller to distinguish between stderr and stdout. For that, you need to call the api in non-blocking mode (_preload_content=False).
Here is what I did to my local code to “resolve” it
I just transposed
self._all += data
a few lines down to not include the channel data.