0

My problem is the following. If I want just the exit code of a command I can do the following inside a shell script:

#!/bin/bash

rV=$(rpm -qi python | 'Version')
echo $? # echo the return code
echo $rv # echo the output produced from the command

With the filedescriptors you can redirect stdin, stdout and stderr to different files and other things. But I don't want to read/write to files. So are there also predefined return values such as '$?' for stdout and stderr, e.g., '$out' and '$err'. And if this is not the case is there a solution similar to this:

#!/bin/bash

#ar is an array
ar=myCommand and some other operations that at the end 'ar' looks like this:
ar=[stdout, stderr, returncode]

Best regards and thx in advance :)

ProgrammingIsAwsome
  • 1,109
  • 7
  • 15
  • 1
    I'm not sure what you're asking. `$?` exists because the return value of a program is not known ahead of time. Standard output and standard error are, by definition, file descriptors 1 and 2 respectively. There's no need for a parameter. – chepner Sep 18 '15 at 15:11
  • Thank you a lot. I now understood the solution in the provided link :D – ProgrammingIsAwsome Sep 24 '15 at 11:18

0 Answers0