How to execute a full shell string without writing it to a file?

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 the ProcessBuilder but it was never executed correctly and I was not able to get the error message.
  • I also tried with su cat << EOF commands_here EOF but 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?



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation