DSExecute

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
morneh
Participant
Posts: 17
Joined: Wed Jan 28, 2004 8:09 am
Contact:

DSExecute

Post by morneh »

Hi

I'm trying a simple dos command using the DSExecute command. However I keep getting a return code of 1 meaning that it doesn't find the command.

The command is a simple 'Copy' but it can't find it.

Anyone have any kind of explanation for this ?

Also, what kind of security/priviledges do I need on the server to execute this ?

They've recently implemented a firewall so that I can't log onto the server with a datastage user anymore. I now need to check the omit username and password option and then it'll allow me to log on. Could this be the problem ? If so, any way to get around it ?

Thanks
Morne
morneh
Participant
Posts: 17
Joined: Wed Jan 28, 2004 8:09 am
Contact:

Post by morneh »

Nevermind *sigh*

It's the arabic characters again...

I've placed the following in a routine

************************************************************
FileNameLength = Len(trim(FileName))
UnQuotedFileName = trim(FileName)[2,FileNameLength - 2]

CommandString = 'Copy /Y E:\devlopment\Source\':FileName:' E:\devlopment\Source\Source.xls'

Call DSExecute("DOS", CommandString, Output, SystemReturnCode)

Ans = SystemReturnCode

************************************************************

It works fine if you give it an English filename. But somewhere the NLS for arabic just goes screwy and it doesn't work.

I'll post again if I find a solution.

Cheerio
Morne
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Morne,

it is not only the Arabic, this would cause an error in non-NLS dos with a space in the filename. Just use double-quotes around the filename and you will be ok. (I've done that with Japanese filenames, so I've encountered the same problem before).

Code: Select all

CommandString = 'Copy /Y "E:\devlopment\Source\':FileName:'" "E:\devlopment\Source\Source.xls"' 
morneh
Participant
Posts: 17
Joined: Wed Jan 28, 2004 8:09 am
Contact:

Post by morneh »

Hi Arnd

I've tried with the double quotes but it still won't work.

Do you perhaps have a dsx export of the program you used and could you mail it to me ?

My email address is kn-mhenderson@se.com.sa

Thanks for all your help so far. It's appreciated :D
Morne
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Sorry, I don't have any of those old projects. Can you do me a favor and test it with embedded spaces - if it works with that it really should work with NLS characters. Do you have right-to-left ordering set in DOS/Windoze?
morneh
Participant
Posts: 17
Joined: Wed Jan 28, 2004 8:09 am
Contact:

Post by morneh »

Embedded spaces in the filename doesn't work either so I'm assuming the double-quote fix is a must. Problem is everytime I used it, it uses the variable name (FileName) as the value. It doesn't resolve the variable first and then add double quotes to it.

I've even tried concatenating a " character to either side of the variable so that it resolves and then adds the quotes, but it doesn't work either.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Morne,

could you post your execute string? It ought to work.
morneh
Participant
Posts: 17
Joined: Wed Jan 28, 2004 8:09 am
Contact:

Post by morneh »

SourceFileName = 'E:\development\Source\':"FileName"
TargetFileName = "E:\development\Source\Source.xls"

CommandString = 'Copy /Y ':SourceFileName:' ':TargetFileName

Call DSExecute("DOS", CommandString, Output, SystemReturnCode)

Ans = SystemReturnCode

Return (Ans)

This returns FileName as the variable name itself but doesn't resolve it.
I've also tried the following:


SourceFileName = 'E:\development\Source\':' " ':FileName:' " '
TargetFileName = "E:\development\Source\Source.xls"

CommandString = 'Copy /Y ':SourceFileName:' ':TargetFileName

Call DSExecute("DOS", CommandString, Output, SystemReturnCode)

Ans = SystemReturnCode

Return (Ans)

Doesn't work either even though this does look correct if I return the commandstring:

Copy /Y E:\development\Source\"Dist - Transformers.xls" E:\development\Source\Source.xls
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Morneh,

what about the command string suggestion that I posted with quotes? And how are you getting a parameter name in there instead of it's value?

Confused,
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
Regarding:
SourceFileName = 'E:\development\Source\':' " ':FileName:' " '
TargetFileName = "E:\development\Source\Source.xls"

CommandString = 'Copy /Y ':SourceFileName:' ':TargetFileName

Call DSExecute("DOS", CommandString, Output, SystemReturnCode)
try:

Code: Select all

SourceFileName = DQuote('E:\development\Source\' : FileName)
TargetFileName = "E:\development\Source\Source.xls"
CommandString = 'copy /Y : SourceFileName:' ':TargetFileName
Call DSExecute("DOS", CommandString, Output, SystemReturnCode)
you should have a command like:
copy /Y "source_file_full_path" "target_file_full_path"
(copy variations using wildcards and such also can be used as long as the copy command is legal)

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
morneh
Participant
Posts: 17
Joined: Wed Jan 28, 2004 8:09 am
Contact:

Post by morneh »

Roy,

I'm not sure if I should kiss you or thank you... for now I'll stick with just thanks :)

It finally works.

Arnd, thanks to you too. Your solution was correct I just couldn't figure out how to implement it.
Post Reply