xpipe-io / xpipe

Your entire server infrastructure at your fingertips
https://xpipe.io
Apache License 2.0
2.7k stars 73 forks source link

Display custom script's output when executed from file manager #304

Closed FMotalleb closed 1 month ago

FMotalleb commented 1 month ago

Thank you for developing Xpipe, a valuable free and open-source application. I appreciate the custom script execution feature in the SFTP mode. However, I've noticed a limitation: there's currently no way to view the output of these custom scripts directly in the file manager interface.

To work around this, I've been using the error reporting option as a makeshift solution to display script output. For instance, when running an MD5 checksum script, I've had to modify it like this:

find ${1:-$PWD} -type f -exec md5sum '{}' \; 1>&2
exit 1

This approach redirects the standard output to standard error (1>&2) and forces an error condition (exit 1) to trigger the error reporting display. While functional, this is not an ideal solution.

I'd like to request a feature enhancement: the ability to view the console output of custom scripts directly in the file manager interface or like the error handler (in a popup) after the execution is done. This would greatly improve the user experience and eliminate the need for workarounds that abuse the error reporting mechanism.

crschnick commented 1 month ago

That makes sense, I will have to think about how to implement that

crschnick commented 1 month ago

So now that I think of it, is there a case of not displaying command output? I could for example implement it like that to always show the command output if there was any on stdout.

The only case in which nothing would be displayed would be if there was no stdout

crschnick commented 1 month ago

Or are there cases in which you want your scripts to not show their output even though they probably print something to stdout?

FMotalleb commented 1 month ago

That's a good point. We could show output whenever stdout exists. If someone really wants to hide the output, they can always use &>/dev/null when running the script.

FMotalleb commented 1 month ago

currently, it will be good enough. and it's normal behavior of a bash script tho.

crschnick commented 1 month ago

I'm currently working on some changes for scripts.

Would it also be ok to give the option to run the script in a terminal? That way you would get your output in a terminal and could also run interactive commands

FMotalleb commented 1 month ago

that's too good to be true.

FMotalleb commented 1 month ago

and another thing, could you add /home to the common section in the sftp view?

crschnick commented 1 month ago

yeah can do that

crschnick commented 1 month ago

You can try out an early version at https://github.com/xpipe-io/xpipe-ptb if you're interested. Also reworked other parts of the scripting system

FMotalleb commented 1 month ago

Thank you!

FMotalleb commented 1 month ago

Thanks for the update. Since the problem is solved, I think we can go ahead and close this issue.

crschnick commented 1 month ago

Feel free to continue using the PTB until the full release, I pushed another PTB update with a few more changes to scripts.