0
我試圖在Java中使用Process或ProcessBuilder對象模擬下面的bash shell腳本的功能。我不清楚我是如何做標準輸入重定向的。我怎樣才能做到這一點?將Bash腳本移植到Java
#
# Redirect shell echo command from standard output to file
# This will construct the input file
#
exec 1> $STDIN
echo -e "$NFILE\n$GFILE\n$INPUT\n$OUTPUT\n$CAX"
exec 1>&-
#
# Run executable redirecting standard in as the input file and output to a log file
#
"$EXE" < $STDIN >& $LOG
爲什麼'exec 1> $ STDIN'?爲什麼不只是'echo -e「...」> $ STDIN' – mob 2009-09-22 15:51:05
@mobrule不確定。我繼承了這個腳本。 exec 1做什麼不同? – javacavaj 2009-09-23 15:17:26