Page 1 of 1

Execute Command Activity stage Issue

Posted: Fri Feb 08, 2013 12:13 am
by Roopanwita
Hi,

My requirement is to call a poweshell script in DataStage Sequencer. I searched and followed same as mention to call script:

viewtopic.php?t=146877

My script is to rename files, when I run the script in powershell, it works fine but as when I am trying to run in Execute Command Activity stage in datastage sequence , it is getting hanged , in logs it says scripts has initiated then it keeps running , it doesn't say anything in log.

For testing, i just wrote a single line powershell script just echo 123, even if I am trying to call this in Execute Command Activity stage it is running indefinitely.

Is there any difference in the way we call shell script and powershell script?

Can anybody please help me to find the issue.

Thank you.

Posted: Mon Feb 11, 2013 8:21 am
by chulett
:!: Please don't feel the need to add your problem on to other's only vaguely related posts. I've removed them so the discussion of your issue can happen here. And here are the two replies that were there that should have been here:
ray.wurlod wrote:Does Powershell need an option to return once the command is complete (like the -c option for sh in UNIX, or the /C switch for DOS in Windows)?
Poovalingam wrote:does this job sequence having the exec command activity alone? It may be in execution in other activities as well. we can try using a small command like echo 'dummy' in the exec command activity to debug.

Posted: Mon Feb 11, 2013 1:55 pm
by Roopanwita
Hi,

Sorry for posting in wrong place.

Thank you for your reply.

I am trying as below :

Created a dummy job only with Execute command Activity stage and wrote echo dummy in Command , this running good and finished successfully, echo dummy in log.

Now I saved same text (echo dummy) in a file name dummy.ps1 called that file in Execute command Activity stage like ./C:\test\dummy.ps1, it gives error
Reply=1
Output from command ====>
'.' is not recognized as an internal or external command,
operable program or batch file.
Then I tried to execute like C:\test\dummy.ps1 in Execute command Activity stage, it doen't fail or complete , it keeps on running , if I am trying to Abort , it is not working .

So can anybody please guide what is going wrong here or how do I need to call a sript.

Thanks you.

Posted: Mon Feb 11, 2013 2:58 pm
by chulett
Now you're mixing UNIX in your DOS command. It doesn't use the "dot slash" like that, remove those two characters and it should run more better.

Posted: Mon Feb 11, 2013 5:43 pm
by Roopanwita
Thank you for reply.

I agree when I am trying to run with ./ it might fail , but in last option i tried to run only the script name with path : C:\test\dummy.ps1
Then I tried to execute like C:\test\dummy.ps1 in Execute command Activity stage, it doen't fail or complete , it keeps on running , evenif I am trying to Abort , it is not working .
Then it keeps on running .

I tried all different execution option mentioned at http://ss64.com/ps/syntax-run.html but nothing is working.

Thank you in advance for help.

Posted: Mon Feb 11, 2013 7:15 pm
by ray.wurlod
Try excaping the backslashes.

Code: Select all

C:\\test\\dummy.ps1 

Posted: Mon Feb 11, 2013 10:17 pm
by chulett
Roopanwita wrote:I agree when I am trying to run with ./ it might fail
Correction - it will fail. As you've seen.

Why the need for "powershell"? Why not a simple batch file?

ps. I haven't seen any evidence posted where you've used the syntax noted at the URL you posted. For example:
The most common (default) way to run a script is by calling it:

PS C:\> & "C:\Belfry\My first Script.ps1"

If the path does not contain any spaces, then you can omit the quotes and the '&' operator

PS C:\> C:\Belfry\Myscript.ps1

If the script is in the current directory, you must indicate this using .\ (or ./ will also work)

PS C:\> .\Myscript.ps1
You seem to be omitting the "PS" part, the part that actually invokes the PowerShell session.

Posted: Thu Feb 14, 2013 11:51 am
by Roopanwita
Hi,

Finally Execute Command Activity is working :

I am calling powershell like : powershell.exe <Script_name with Path>

I need to change window setting Set -ExecutionPolicy RemoteSigned

Below link was helpful :
Thank you for help.