John, try the following commands.
Here is a direct powershell command through staf:
C:\work\bin>staf local process start shell command "ps" WAIT STDERRTOSTDOUT
RETURNSTDOUT
Response
--------
{
Return Code: 0
Key : <None>
Files : [
{
Return Code: 0
Data :
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
134 6 2096 4072 35 0.48 5180 alg
34 2 664 2732 26 0.52 1192 ApacheMonitor
36 2 484 1988 18 0.94 5728 ApMsgFwd
38 2 912 2836 28 0.09 5820 ApntEx
109 4 4176 7392 39 0.36 4612 Apoint
129 6 2856 3712 25 0.34 1188
AppleMobileDeviceService
136 5 12344 12088 91 5.64 1372 AppLogService
199 6 3140 8860 58 2.66 1948 BCMWLTRY
294 12 17188 9380 91 25.28 2384 BESClient
208 5 6744 1124 66 0.47 5100 BESClientUI
207 7 4148 432 42 0.53 2572 ccApp
441 9 5968 2048 54 3.91 932 ccSvcHst
33 2 2028 2756 30 0.09 3448 cmd
37 2 2036 148 30 0.11 4916 cmd
40 2 2044 148 30 0.14 6068 cmd
Here I have a powershell script that I can run through staf:
I have a simple powershell script that just determines the host os version
called ps_os_version.ps1, which resides in my C:\work\bin directory. If I want
to run the powershell command through staf, I do the following:
C:\work\bin>staf local process start shell command
"C:\work\bin\ps_os_version.ps1" workdir "c:\work\bin" WAIT STDERRTOSTDOUT
RETURNSTDOUT
Response
--------
{
Return Code: 0
Key : <None>
Files : [
{
Return Code: 0
Data :
SystemDirectory : C:\WINNT\system32
Organization : SAS Institute Inc.
BuildNumber : 2600
RegisteredUser : George Flaherty
Version : 5.1.2600
}
]
}
-George
On May 20, 2011, at 12:17 PM, Sharon Lucas <luc...@us.ibm.com> wrote:
> Return code 75 is not a STAF return code. It appears that there are some
> things wrong with your command:
>
> 1) You used a \" to nest a double quote within a double quote for the first
> double quote, but you also need to use \" for the ending quote. Also, I
> would use / instead of \ within the file name to avoid problems with escape
> characters. For example:. Change:
> \"C:\Program Files\Hi\PSSnapin\PSSnapin.psc1"
> to
> \"C:/Program Files/Hi/PSSnapin/PSSnapin.psc1\"
>
> 2) You are specifying .\test.ps1. Is the .\ supposed to be indicating the
> current directory? If so, note that the current directory is whatever
> directory that STAFProc was started from as a process started via STAF runs
> in the environment in which STAFProc is running (not the environment of the
> command line from which it was started). You should either fully qualify the
> location of test.ps1 and use / instead of \ in the path name (e.g.
> C:/test.ps1 or whereever it is located) or use the WORKDIR option to specify
> the working directory for the process.
>
> 3) It appears you're missing missing "-Command" in front of C:/test.ps1 in
> your powershell command. However, I don't know anything about powershell so
> I could be wrong. I don't even know if you can specify both arguments for
> powershell. The syntax for powershell is:
>
> C:\>powershell /?
>
> PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
> [-NoLogo] [-NoExit] [-Sta] [-NoProfile] [-NonInteractive]
> [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
> [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
> [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
> [-Command { - | <script-block> [-args <arg-array>]
> | <string> [<CommandParameters>] } ]
>
> You should run your powershell command first without STAF to verify that you
> are running a valid powershell command.
>
> Note that a STAF PROCESS START request simply starts the process (and
> monitors for when it completes if the WAIT option is specified). It doesn't
> matter what the process does as STAF is not really part of the picture while
> the process is running. It more likely has something to do with the
> process's use of stdin, stdout, or stderr as STAF does do some things
> regarding them when starting the process. You could try not specifying
> RETURNSTDERR or RETURNSTDOUT to see if it works. The process's "Return Code"
> should indicate if it worked.
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin, luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
>
>
>
>
> From: John Andoh <john.an...@gmail.com>
> To: Sharon Lucas/Austin/IBM@IBMUS
> Cc: staf-users@lists.sourceforge.net, John Andoh
> <john.an...@gmail.com>
> Date: 05/20/2011 04:23 AM
> Subject: Re: [staf-users] Using STAF with a powershell snapin
>
>
>
> Hi Sharon,
>
> With the -PSConsoleFile parameter, the STAF command produced a Response code
> of 75:
>
> C:\>
> C:\>staf local process start command
> "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile
> \"C:\Program Files\Hi\PSSnapin\PSSnapin.psc1" -NoExit .\test.ps1 ; exit" wait
> returnstderr returnstdout
> Response
> --------
> 75
> C:\>
> C:\>
>
> What is Response code 75? The code is undefined in this document:
>
> http://staf.sourceforge.net/current/STAFRC.htm
>
> Regards,
> John Andoh
>
>
> On Thu, May 19, 2011 at 4:18 PM, John Andoh <john.an...@gmail.com> wrote:
> Hi Sharon,
>
> Thanks for the quick response.
> The command failed and produced the same error message.
>
>
> C:\>STAF local PROCESS START SHELL COMMAND "powershell -ExecutionPolicy
> UNRESTRICTED -command C:\\test.ps1" WAIT RETURNSTDOUT RETURNSTDERR
> SAMECONSOLE
> Response
> --------
> {
> Return Code: 0
> Key : <None>
> Files : [
> {
> Return Code: 0
> Data :
> }
> {
> Return Code: 0
> Data : Add-PSSnapin : No snap-ins have been registered for
> Windows PowerShell version 2.
> At C:\test.ps1:3 char:13
> + add-pssnapin <<<< Storage.Management.Powershell.Admin
> + CategoryInfo : InvalidArgument:
> (Storage...owershell.Admin:String) [Add-PSSnapin], PSArgumentException
> + FullyQualifiedErrorId :
> AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
>
> The term 'get-subsystem' is not recognized as the name of a cmdlet, function,
> script file, or operable program. Check the spelling of the name, or if a
> path was included, verify that the pa
> th is correct and try again.
> At C:\test.ps1:4 char:14
> + get-subsystem <<<<
> + CategoryInfo : ObjectNotFound: (get-subsystem:String) [],
> CommandNotFoundException
> + FullyQualifiedErrorId : CommandNotFoundException
>
>
> }
> ]
> }
>
> The script is attempting to spawn a process with the snapin and execute a
> cmdlet implemented by the snapin.
> This capability is available with Shell scripts. How is this function
> implemented with STAF? Please advise. Thanks!
>
> Regards,
> John Andoh
>
>
>
>
>
> On Thu, May 19, 2011 at 3:50 PM, Sharon Lucas <luc...@us.ibm.com> wrote:
> I don't know anything about Powershell snapins. But, if you specify the
> following does it work?
>
> C:\>STAF local PROCESS START SHELL COMMAND "powershell -ExecutionPolicy
> UNRESTRICTED -command C:\\test.ps1" WAIT RETURNSTDOUT RETURNSTDERR
> SAMECONSOLE
>
> --------------------------------------------------------------
> Sharon Lucas
> IBM Austin, luc...@us.ibm.com
> (512) 286-7313 or Tieline 363-7313
>
>
>
>
> From: John Andoh <john.an...@gmail.com>
> To: staf-users@lists.sourceforge.net
> Date: 05/19/2011 05:34 PM
> Subject: [staf-users] Using STAF with a powershell snapin
>
>
>
>
> Dear staf-users,
>
> I am having problems running a Powershell script, test.ps1, with the "STAF
> PROCESS START SHELL" command.
> The script loads a Powershell snapin, Storage.Management.Powershell.Admin,
> and executes a command, get-subsystem, implemented by the snap-in.
>
> This is the content of the powershell script, test.ps1.
>
>
> C:\>type test.ps1
>
>
> add-pssnapin Storage.Management.Powershell.Admin
> get-subsystem
> C:\>
> C:\>
>
> This is the expected result for running the script in the DOS command prompt:
>
>
> C:\>powershell.exe -ExecutionPolicy UNRESTRICTED -command c:\test.ps1
>
> There is no subsystems added.
>
>
> However, if the powershell script is run with "STAF PROCESS START SHELL"
> command, I ran into problems registering the snapin, as seen from the error
> messages below:
>
>
>
> C:\>STAF local PROCESS START SHELL "powershell.exe -ExecutionPolicy
> UNRESTRICTED -command %c" COMMAND c:\test.ps1 WAIT RETURNSTDOUT RETURNSTDERR
> SAMECONSOLE
> Response
> --------
> {
> Return Code: 0
> Key : <None>
> Files : [
> {
> Return Code: 0
> Data :
> }
> {
> Return Code: 0
> Data : Add-PSSnapin : No snap-ins have been registered for
> Windows PowerShell version 2.
> At C:\test.ps1:3 char:13
> + add-pssnapin <<<< Storage.Management.Powershell.Admin
> + CategoryInfo : InvalidArgument:
> (Storage...owershell.Admin:String) [Add-PSSnapin], PSArgumentException
> + FullyQualifiedErrorId :
> AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
>
> The term 'get-subsystem' is not recognized as the name of a cmdlet, function,
> script file, or operable program. Check the spelling of the name, or if a
> path was included, verify that the pa
> th is correct and try again.
> At C:\test.ps1:4 char:14
> + get-subsystem <<<<
> + CategoryInfo : ObjectNotFound: (get-subsystem:String) [],
> CommandNotFoundException
> + FullyQualifiedErrorId : CommandNotFoundException
>
>
> }
> ]
> }
>
> C:\>
>
>
> I will appreciate your help to resolve this problem. Thanks.
>
>
> Regards,
> John Andoh
>
> ------------------------------------------------------------------------------
> What Every C/C++ and Fortran developer Should Know!
> Read this article and learn how Intel has extended the reach of its
> next-generation tools to help Windows* and Linux* C/C++ and Fortran
> developers boost performance applications - including clusters.
> http://p.sf.net/sfu/intel-dev2devmay_______________________________________________
> staf-users mailing list
> staf-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/staf-users
>
>
>
> ------------------------------------------------------------------------------
> What Every C/C++ and Fortran developer Should Know!
> Read this article and learn how Intel has extended the reach of its
> next-generation tools to help Windows* and Linux* C/C++ and Fortran
> developers boost performance applications - including clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> staf-users mailing list
> staf-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users