I have a shell (.sh) file that it is multi-line and has functions inside it as a string and I want to execute it entirely without the need to write it to to a .sh file.
- I tried with
Process process = Runtime.getRuntime().exec(commands)and theProcessBuilderbut it was never executed correctly and I was not able to get the error message. - I also tried with
su cat << EOF commands_here EOFbut also never finished
I believe the error comes because it has functions inside it and not only one command per line.
Is there a way to execute such shell's string without the need to write it to disk and using ./file.sh?