Page 1 of 1

DSExecute

Posted: Wed Apr 06, 2005 1:12 am
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

Posted: Wed Apr 06, 2005 3:37 am
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

Posted: Wed Apr 06, 2005 5:53 am
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"' 

Posted: Wed Apr 06, 2005 7:40 am
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

Posted: Wed Apr 06, 2005 8:38 am
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?

Posted: Sat Apr 09, 2005 1:36 am
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.

Posted: Sat Apr 09, 2005 8:30 am
by ArndW
Morne,

could you post your execute string? It ought to work.

Posted: Sun Apr 10, 2005 12:06 am
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

Posted: Sun Apr 10, 2005 5:36 am
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,

Posted: Sun Apr 10, 2005 6:50 am
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,

Posted: Sun Apr 10, 2005 7:11 am
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.