Quote:> Hi,
> Please help. I tried to set up a cron job to:
> 1. Open xterm window
> 2. Run my script from this xterm
> 3. display any errors or output from the script to this xterm.
> The reason I need this because the script that I launch from cron job
> required user input and it could NOT feed in with regular <<EOF option.
Well, something like:
#! /bin/ksh
MYPATH=/path/to/my/bin/directory:/path/to/my/script/directory
MYCMD="myscript args..."
export PATH="/usr/bin:/usr/X/bin:/usr/openwin/bin:${MYPATH}"
ConsoleXuser="$(who|awk '$2=="console" && $NF=="(:0)" {print $1}')"
if [ "${ConsoleXuser}" = "${LOGNAME}" ]; then
xterm -display :0 -e ${MYCMD}
else
print -u 2 -r - \
"User $LOGNAME not console X user at this time; script not run"
fi
(in another script, itself run from cron) might work. But if it doesn't
actually require human judgement, but is merely a sticking point of the
program being run that it expects terminal input, scrounge and use
"expect" (www.sunfreeware.com has it precompiled, I think) which uses
pseudo-ttys to communicate with a program and can script its interaction
with that program. That is, unless the program itself is something that
needs an X display for input, "expect" should be quite able to get around
its inability to deal with <<EOF input.
--