0

How to Pass a Terminal error into the Python program whenever the error is triggered in the terminal?

Example:

Consider I'm running a java program and I get some error like this

file.java:2: error: ',', ')', or '[' expected
    public static void main(String args...) {
                                       ^
1 error

Another example by entering the wrong bash command

ls: option '--a' is ambiguous; possibilities: '--all' '--almost-all' '--author'
Try 'ls --help' for more information.

I need to pass this error to a python program and run the program whenever the terminal shows the error like this.

How can I pass the error?

Yogi
  • 609
  • 1
  • 8
  • 21
  • What you mean by "pass this error". There can be long error. Do you want to pass any specific error keyword to your script? – PySaad Jul 19 '19 at 11:19
  • @py_saad I want to pass the entire error as a string to the constructor. – Yogi Jul 19 '19 at 11:21
  • 1
    Do you want to pipe `|` the error into a Python script? In this case, [this may help](https://stackoverflow.com/q/2342826/1639625) – tobias_k Jul 19 '19 at 11:25

0 Answers0