I don't think this really has anything to do with aliases.  If you run "fc 
-l" via a STAF PROCESS START request, I think you will see the same 
results.  Since these specific shell utilities "history" and "fc -l" deal 
with commands previously entered to an interactive sh, I don't think you 
will be able to use them via a STAF PROCESS.  (And note that on my Linux 
system, I was able to use "history" without creating it as an alias to 
another command).

If I try to run "history" or "fc -l" via STAF, I get the same blank output 
(but the process is successful, i.e the process return code is 0):

# STAF local PROCESS START SHELL COMMAND "history" RETURNSTDOUT 
STDERRTOSTDOUT WAIT
Response
--------
{
  Return Code: 0
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       :
    }
  ]
}

# STAF local PROCESS START SHELL COMMAND "fc -l" RETURNSTDOUT 
STDERRTOSTDOUT WAIT
Response
--------
{
  Return Code: 0
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       :
    }
  ]
}

And if I run these requests from the command line ("history", "fc -l"), I 
do get output.

However, if I run the following, i.e. start a shell and execute those 
commands:

# sh -c history

# sh -c fc -l

#

Notice the commands are successful but there is nothing in the output, 
which is the same as when you run these commands via STAF.

Also note that if you don't specify the SHELL option, then since these are 
not actual executables on the system, the PROCESS START will fail:

# STAF local PROCESS START COMMAND "history" RETURNSTDOUT STDERRTOSTDOUT 
WAIT
Error submitting request, RC: 10
Additional info
---------------
Command does not exist: history

# STAF local PROCESS START COMMAND "fc" PARMS "-l" RETURNSTDOUT 
STDERRTOSTDOUT WAIT
Error submitting request, RC: 10
Additional info
---------------
Command does not exist: fc

# which history
/usr/bin/which: no history in 
(/usr/local/staf/bin:/usr/local/staf/bin:/usr/kerb
eros/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:
/usr/bin:/root/bin)

# which fc
/usr/bin/which: no fc in 
(/usr/local/staf/bin:/usr/local/staf/bin:/usr/kerberos/
sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/
bin:/root/bin)

So to run without the SHELL option, you would need to use the shell as the 
command, which gives you the same blank output:

# STAF local PROCESS START COMMAND "sh" PARMS "-c history" RETURNSTDOUT 
STDERRTOSTDOUT WAIT
Response
--------
{
  Return Code: 0
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       :
    }
  ]
}

# STAF local PROCESS START COMMAND "sh" PARMS "-c fc -l" RETURNSTDOUT 
STDERRTOSTDOUT WAIT
Response
--------
{
  Return Code: 0
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       :
    }
  ]
}
 
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: bda...@us.ibm.com 
 





From:
"Uma Maheswar Chilukuri" <u...@mach.com>
To:
David Bender/Austin/i...@ibmus
Cc:
staf-users@lists.sourceforge.net
Date:
01/14/2010 11:09 PM
Subject:
[staf-users] Executing aliases using PROCESS service



Hi David,
This is in response to your suggested solution.
Part of this below mail is sent to mail list for another response.
Results of your suggested solutions are at end of the mail.
"history" is aliased to 'fc -l' as you can see below.
[test:~]$alias
alias history='fc -l'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias perl='/usr/bin/perl5.8.5'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot 
--show-tilde'

Here if "history" is executed with STAF it doesn't return anything. 
(Please note that this is not executed on remote machine for which this 
thread has been started)
[test:~]$STAF local PROCESS  START SHELL COMMAND "history" returnstdout 
stderrtostdout wait Response
--------
{
  Return Code: 0
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       :
    }
  ]
}
Executing "history" without staf returns results.
[test:~]$history
1049     cd
1050     whoami
1051     ls
1052     ls
1053     ls
1054     ls
1055     history
1056     ls
1057     ls
1058     sl
1059     ls
1060     ls
1061     history
1062     alias
1063     STAF local process start shell returnstdout wait command alias
1064     alias
1065     STAF local PROCESS  START SHELL COMMAND "history" returnstdout 
stderrtostdout wait
[test:~]$
Now If “history” is executed as you suggested following is the result. 
[test:~]$STAF local PROCESS  START SHELL COMMAND "`history`" returnstdout 
stderrtostdout wait
Response
--------
{
  Return Code: 127
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       : sh: 1050: command not found
sh: line 1: 1051: command not found
sh: line 2: 1052: command not found
sh: line 3: 1053: command not found
sh: line 4: 1054: command not found
sh: line 5: 1055: command not found
sh: line 6: 1056: command not found
sh: line 7: 1057: command not found
sh: line 8: 1058: command not found
sh: line 9: 1059: command not found
sh: line 10: 1060: command not found
sh: line 11: 1061: command not found
sh: line 12: 1062: command not found
sh: line 13: 1063: command not found
sh: line 14: 1064: command not found
sh: line 15: 1065: command not found
sh: line 16: 1066: command not found
    }
  ]
}
[test:~]$STAF local PROCESS  START SHELL COMMAND "echo `history`" 
returnstdout stderrtostdout wait
Response
--------
{
  Return Code: 127
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       : 1051 ls
sh: line 1: 1052: command not found
sh: line 2: 1053: command not found
sh: line 3: 1054: command not found
sh: line 4: 1055: command not found
sh: line 5: 1056: command not found
sh: line 6: 1057: command not found
sh: line 7: 1058: command not found
sh: line 8: 1059: command not found
sh: line 9: 1060: command not found
sh: line 10: 1061: command not found
sh: line 11: 1062: command not found
sh: line 12: 1063: command not found
sh: line 13: 1064: command not found
sh: line 14: 1065: command not found
sh: line 15: 1066: command not found
sh: line 16: 1067: command not found
    }
  ]
}
Thanks,
Uma.
------------------------------
I don't think this has anything to do with the alias being defined in the 
profile.  I can reproduce the problem just from some command line 
requests.  Here is what I  found (on a  Linux system), including a 
workaround.
First, define an alias (have "osname" run the "uname" command): 
# osname
-bash: osname: command not found
# uname
Linux
# alias osname=uname
# osname
Linux
 
Using "osname" as the PROCESS COMMAND results in an error similar to
yours:
 
# STAF local PROCESS START SHELL COMMAND "osname" RETURNSTDOUT 
STDERRTOSTDOUT WAIT Response
--------
{
  Return Code: 127
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       : sh: osname: command not found
    }
  ]
}
If we use backticks around osname, then that does execute the aliased 
command, but then the shell tries to execute the output (in this case
"Linux"):
# STAF local PROCESS START SHELL COMMAND "`osname`" RETURNSTDOUT 
STDERRTOSTDOUT WAIT Response
--------
{
  Return Code: 127
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       : sh: Linux: command not found
    }
  ]
}
So, if you do something like "echo `osname`", that works:
# STAF local PROCESS START SHELL COMMAND "echo `osname`" RETURNSTDOUT 
STDERRTOSTDOUT WAIT Response
--------
{
  Return Code: 0
  Key        : <None>
  Files      : [
    {
      Return Code: 0
      Data       : Linux
    }
  ]
}
Maybe someone else on the mailing list has a better solution.
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: bda...@us.ibm.com 
 
--
Uma.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for 
Conference
attendees to learn about information security's most important issues 
through
interactions with peers, luminaries and emerging and established 
companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users



------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to