Maybe you're getting the "standard in must be a tty" error note due to using "su" but because the db2 command is asking you to respond to a prompt?
Does the following work (e.g. running the env command instead of a db2
command) and not return the "standard in must be a tty" error ?
# STAF local PROCESS START SHELL "su - %u -c %C" COMMAND :3:env USERNAME
db2inst1 RETURNSTDOUT STDERRTOSTDOUT WAIT
Does the following work? It adds /home/db2inst1/sqllib/bin,
/home/db2inst/sqllib/adm, and /home/db2inst1/sqllib/misc to the PATH
environment variable for this process and sets the DB2INSTANCE environment
variable to db2inst1 (these are things done by sourcing
/home/db2inst1/sqllib/db2profile) and specifies the entire command via the
COMMAND option (doesn't use the PARMS option)?.
# STAF local PROCESS START SHELL "su - %u -c %C" COMMAND
"/home/db2inst1/sqllib/bin/db2 list database directory" USERNAME db2inst1
ENV
"PATH=/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:{STAF/Env/PATH}"
ENV "DB2INSTANCE=db2inst1" RETURNSTDOUT STDERRTOSTDOUT STDIN
/tmp/empty.txt WAIT
Note: /tmp/empty.txt is an empty file that you already created on the
machine where the process is being run)
If that doesn't work, perhaps /home/db2inst1/sqllib/db2profile needs to
be run (as it is automatically if you log on as the db2inst1 user) before
the db2 command can be run. I googled and found "Before you can issue DB2
commands on UNIX systems, you must first set up the environment by
sourcing the db2profile". Maybe try the following:
# STAF local PROCESS START SHELL "su - %u -c %C" COMMAND
"/home/db2inst1/sqllib/db2profile; /home/db2inst1/sqllib/bin/db2 list
database directory" USERNAME db2inst1 RETURNSTDOUT STDERRTOSTDOUT STDIN
/tmp/empty.txt WAIT
or
# STAF local PROCESS START SHELL "su - %u -c %C" COMMAND ".
/home/db2inst1/sqllib/db2profile; /home/db2inst1/sqllib/bin/db2 list
database directory" USERNAME db2inst1 RETURNSTDOUT STDERRTOSTDOUT STDIN
/tmp/empty.txt WAIT
Or maybe need to run db2start before the db2 command can be run. Maybe
try the following:
# STAF local PROCESS START SHELL "su - %u -c %C" COMMAND
"/home/db2inst1/sqllib/bin/db2start; /home/db2inst1/sqllib/bin/db2 list
database directory" USERNAME db2inst1 ENV
"PATH=/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:{STAF/Env/PATH}"
ENV "DB2INSTANCE=db2inst1" RETURNSTDOUT STDERRTOSTDOUT STDIN
/tmp/empty.txt WAIT
--------------------------------------------------------------
Sharon Lucas
IBM Austin, [email protected]
(512) 286-7313 or Tieline 363-7313
From: <[email protected]>
To: David Bender/Austin/IBM@IBMUS
Cc: [email protected]
Date: 04/14/2011 11:57 PM
Subject: Re: [staf-users] Starting a process with different user on
Linux (RHEL4)
Hi David,
I had tried this solution.
I had commented the "Defaults requiretty" line in
/etc/sudoers. But with that also it has not solved the problem
Also I tried creating /tmp/test.out and passed it to STDIN, but still the
problem persists:
[root@rhel5-db2-97 ~]# staf local process start shell "su - %u -c %C"
command "/home/db2inst1/sqllib/bin/db2" parms "list database directory"
username db2inst1 returnstdout returnstderr wait STDIN /tmp/test.out
Response
--------
{
Return Code: 1
Key : <None>
Files : [
{
Return Code: 0
Data :
}
{
Return Code: 0
Data : standard in must be a tty
}
]
}
Still searching for the solution.
Regards
Sanjeev
From: David Bender [mailto:[email protected]]
Sent: Thursday, April 14, 2011 7:30 PM
To: Lohchab, Sanjeev
Cc: [email protected]
Subject: Re: [staf-users] Starting a process with different user on Linux
(RHEL4)
I found the following site that describes this error and some possible
solutions:
http://superuser.com/questions/119376/bash-su-script-giving-an-error-standard-in-must-be-a-tty
You could also try creating an empty file on the machine where the process
is executing (for example /tmp/stdin.txt) and then add the STDIN option to
your PROCESS START, and see if that makes any difference. For example:
staf local process start shell "su - db2inst1 -c %C" command
"/home/db2inst1/sqllib/bin/db2" parms "list database directory" username
db2inst1 returnstdout returnstderr wait STDIN /tmp/stdin.txt
Thanks,
David
David Bender
STAF/STAX Development
IBM Software Group, WPLC
11501 Burnet Rd.
Bldg. 903-5B002
Austin, TX 78758-3400
Phone (T/L): 1-512-286-5315 (363-5315)
ITN: 23635315
Email: [email protected]
---04/14/2011 05:50:36 AM---I tried without the "su -", but the command
fails since the command has to be run as db2inst1 and si
From:
<[email protected]>
To:
<[email protected]>, <[email protected]>
Date:
04/14/2011 05:50 AM
Subject:
Re: [staf-users] Starting a process with different user on Linux (RHEL4)
I tried without the "su -", but the command fails since the command has to
be run as db2inst1 and since the staf is running as root. So I have only
this workaround to run with su - option.
Regards
Sanjeev
-----Original Message-----
From: Stefano Guandalini [mailto:[email protected]]
Sent: Thursday, April 14, 2011 4:02 PM
To: [email protected]
Cc: Lohchab, Sanjeev
Subject: Re: [staf-users] Starting a process with different user on Linux
(RHEL4)
Have you tried the same without the "su - db2inst1 - ..." part?
I'm not using the internal staf process service, but I know that the STAX
process tag is using it and I'm not using the "su - username" in command
tag.
On Thursday 14 April 2011 12:14:29 [email protected] wrote:
> Hi,
>
> I am automating the DB2 interface to our product.
>
> I have started the staf as root, now I am trying to run the DB2 commands
> using staf process. I ran the following command:
>
> staf local process start shell "su - db2inst1 -c %C" command
> "/home/db2inst1/sqllib/bin/db2" parms "list database directory" username
> db2inst1 returnstdout returnstderr wait
>
> but it is giving error:
>
> Response
> --------
> {
> Return Code: 1
> Key : <None>
> Files : [
> {
> Return Code: 0
> Data :
> }
> {
> Return Code: 0
> Data : standard in must be a tty
>
> }
> ]
> }
>
> I tried googling for this error, but couldn't get any help. I would
> appreciate if any of the experts help me in resolving this issue.
>
> Regards
> Sanjeev
>
>
>
---------------------------------------------------------------------------
> --- Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and
improve
> application availability and disaster protection. Learn more about
boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> staf-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/staf-users
--
Stefano Guandalini
Mobile Quality Assurance
Dada.net S.p.A.
+393666000995
[email protected]
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about
boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
staf-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about
boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
staf-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/staf-users
<<image/gif>>
<<image/png>>
<<image/png>>
<<image/png>>
<<image/png>>
<<image/png>>
<<image/png>>
<<image/png>>
<<image/png>>
------------------------------------------------------------------------------ Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________ staf-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/staf-users
