$server]) }}',
async run() {
this.running = true
this.output = this.command + '\n'
const fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
},
body: JSON.stringify({
user: this.user,
command: this.command,
}),
}
this.command = ''
const response = await fetch(this.runUrl, fetchOptions)
const reader = response.body.getReader()
const decoder = new TextDecoder('utf-8')
while (true) {
if (! this.running) {
reader.cancel()
this.output += '\nStopped!'
break
}
const { value, done } = await reader.read()
if (done) break
const textChunk = decoder.decode(value, { stream: true })
this.output += textChunk
document.getElementById('console-output').scrollTop =
document.getElementById('console-output').scrollHeight
}
this.output += '\nDone!'
this.running = false
},
stop() {
this.running = false
},
}"
>
Headless Console
Here you can run ssh commands on your server and see the result right away.
Note that
this is a headless console, it doesn't keep the current path. it will always run from the home path of
the selected user.