Execute Command Activity stage Issue

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Roopanwita
Participant
Posts: 125
Joined: Mon Sep 11, 2006 4:22 am
Location: India

Execute Command Activity stage Issue

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Roopanwita
Participant
Posts: 125
Joined: Mon Sep 11, 2006 4:22 am
Location: India

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Roopanwita
Participant
Posts: 125
Joined: Mon Sep 11, 2006 4:22 am
Location: India

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try excaping the backslashes.

Code: Select all

C:\\test\\dummy.ps1 
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Roopanwita
Participant
Posts: 125
Joined: Mon Sep 11, 2006 4:22 am
Location: India

Post 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.
Post Reply