store os-command output to a variable

I do not think that this is possible, 'cus Lord knows I have tried, but I will throw it out there.

I would like to store the output of an os-command into a variable. I know that I could have the output stored to a file on the os and the content read back into the procedure, but I thought that maybe I could make it cleaner.

Situation:
I have a user that has a session that needs to be killed. I can only kill in promon as root, but that is dangerous to let the support group do that.
I have a procedure that, when run, generates a list of users to disconnect. The support group selects the user and a cron job, run as root, performs the kill in promon using a keyfile generated by the procedure.

Problem:
Recently we addded ODBC to the mix and now we have a single db user and all others show up in promon as blank (curses!).

Proposed resolution:
Go out and match the pid with the user that created it on the OS. This will now allow the list to contain the info that the support group needs; problem solved.

So...
I know what I need to do. I just want to make it as clean as possible. If I get the pid from the os, using os-command, can I store it directly to a variable (or am I SOL?)

Any suggestions?
 
Linux:
OS-COMMAND VALUE ("sudo sh -c ""proshut dbname -C disconnect " + string (id-user) + """").

Make sure change /etc/sudoers file

#This file gives a right to any user of group "progress" to execute sudo command and disconnect process.
# User privilege specification
root ALL=(ALL) ALL
progress ALL=(ALL) ALL


# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
progress ALL=(ALL) NOPASSWD: ALL
 
This info, though informative, misses the mark. My issue is that I do not no the User's ID (that being the OS id of the user logging into the application). I need this information for support to identify the progress user-id to select for dicsonnect. And that is what I am looking for.

Here is a bit of the code that I have started with.

[FONT=r_ansi][FONT=r_ansi]def var get-pid-user as char format "x(70)".
assign get-pid-user = "ps -ef | grep _progres | grep ".
[FONT=r_ansi][FONT=r_ansi]For Each _Connect WHERE _connect-Type = "SELF" no-lock:
if _Connect-Name = " " then do:
[/FONT]
[/FONT]assign get-pid-user = get-pid-user + " 13913".
assign get-pid-user = get-pid-user + " | awk -F~" ~" ~'~{print ~$1~}~'".

os-command silent value(get-pid-user).
[/FONT]
[/FONT]
 
Maxim,
The issue is not how to disconnect a user. It is that the user name does not exist. Our support group is not going to know who to disconnect. This is why I have to first sync the _Connect.PID value to the user on the OS to which that PID belongs. Here is a snippet of the code:

[FONT=r_ansi][FONT=r_ansi]def var c-user as char.
def var c-user1 as char.
def var c-user2 as char.

c-user1 = "ps -ef | grep ".
c-user2 = " | grep _progres | awk -F~" ~" ~'~{print $1~}~'".

For Each _Connect WHERE _connect-Type = "SELF" no-lock:
if _Connect-Name = " " then do:
c-user = c-user1 + string(_Connect-Pid) + c-user2.
/*Now somehow assign "os-command silent value( c-user)" output to a variable so that I can pass the user id to a
selectable list for support. Then run proshut with disconnect option for the user's progress id*/
end.
end.
[/FONT]
[/FONT]
 

GregTomkins

Active Member
You know about INPUT THROUGH x, right, where 'x' can be any Unix command, and you can then do IMPORTs or READKEYs to process the response from Unix?
 
field _Connect._Connect-Usr is user-id to disconnect.

define variable user-id as integer.
For Each _Connect WHERE _connect-Type = "SELF" and Connect-Name = " " and _Connect-PID = process-pid no-lock:
user-id = _Connect._Connect-Usr.

OUTPUT THROUGH value(yourappname with root right).
put unformatted user-id.
OUTPUT close.
end.

but if you just plan to read output then:
define var outputvar as character.
input through value (c-user).
import outputvar.
input close.
 
Greg,
This is what I am looking for! I am not familiar with the INPUT FROM command. I have not yet tried it, but if it will allow me to run my OS command and collect the output from that command, super!

Thanks!
 
Top