Use async await with cockpit.script() or cockpit.spawn() #20518
Unanswered
neetabisht
asked this question in
Q&A
Replies: 1 comment 6 replies
|
This needs some unpacking.
Ugh, please don't do that -- there are so many things wrong here. It also nicely illustrates the problem with shell: Have a You want await cockpit.spawn(['chmod', '777', '/etc.resolv.conf'], { superuser: "required" });But moreover, never do this on a production system with actual users -- making resolv.conf world-writable is a major security hole. (It may be an okay hack in some non-login VM, but you must know what you are doing) And for reading the file, please use the proper file API: const filedata = await cockpit.file("/etc/resolv.conf").read(); |
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Explain what happens
Hi,
Here are my few queries. can anyone please suggest.
Here is my program:
Here in this program I want saveFileDataForCreateOpr() to be executed completely before moving to subsequent code in registerData() function. Basically let otel_pod = cockpit.script(
${rootpath}EdgeniusConfigurationJs/otel_update.sh); line should be executed only after saveFileDataForCreateOpr() is completed.1 fix i gave inside saveFileDataForCreateOpr() as below:
let filedata = await cockpit.spawn(["cat", "/etc/resolv.conf"], { err: "out" });
For another function filepermissionforcreateopr() i am not getting how to give cockpit.spawn().
Thus wanted to know what best solution can be given in this scenario.
Version of Cockpit
No response
Where is the problem in Cockpit?
None
Server operating system
None
Server operating system version
No response
What browsers are you using?
No response
System log
No response
All reactions