Hi,
I want to write a script which should be run only on foreground. Is there any way that the script can check itself whether it was run using nohup or ksh and if the user runs the script using nohup then it should prompt the user to run it using ksh?
If (The user triggers the script using nohup)
{
The script should echo that the script should be run using ksh (ie, foreground) and exit.
}
Else
{
The script should run fine.
}
Please help. Thanks in advance.
RRVARMA
---------- Post updated at 06:59 PM ---------- Previous update was at 05:55 PM ----------
I tried giving something like this.. the script name is nohup_ksh_testing.sh..
#! /usr/bin/ksh
set -xe
echo "This Process is designed and developed to run on foreground.";
fg %1
echo "This Process is currently running in foreground.";
i ran this as
>> ksh nohup_ksh_testing.sh
I got the result as
$ ksh nohup_ksh_testing.sh
+ echo This Process is designed and developed to run on foreground.
This Process is designed and developed to run on foreground.
+ fg %1
$
I tried to run the same script using nohup as
>> nohup nohup_ksh_testing.sh > testing.log &
I got the result as
$ more testing.log
+ echo This Process is designed and developed to run on foreground.
This Process is designed and developed to run on foreground.
+ fg %1
$
Neither of the case got the script to echo the second text ie,
echo "This Process is currently running in foreground.";
which is after "fg %1" command..