Linux command input done in Java
Many commands in Linux take input one of two ways, stdin, or as an argument to a file. Examples:
Code:
echo "text from stdin" | lpr |
I haven't needed to often but in the past I've just tested whether stdin was a pipe and if not then check for data passed via argument .. here's a perl fragment that may clarify:
Code:
if ( -p STDIN ) { |
Check the number of arguments (argv.length). If positive, there are parameters (filenames), otherwise read strin.
|
All times are GMT -5. The time now is 01:12 AM. |