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

Reply via email to