Page 1 of 1

Rename the txt file

Posted: Thu Dec 07, 2006 7:27 am
by Poonam Singh
Hi,

I am trying to rename the ppff1206.txt to ppff1206.txt.bak and I wrote following code.


Call DSExecute ("NT", mv "/ss/ppff":FileNameSuffix:".txt" to "/dd/ppff":FileNameSuffix:".txt.bak" )

when I compile it it gives following error

Compiling: Source = 'RT_BP1572/JOB.942475120.DT.1422056425', Object = 'RT_BP1572.O/JOB.942475120.DT.1422056425'
*****************************************************************************************************************
WARNING: Variable 'mv' never assigned a value.
WARNING: Variable 'to' never assigned a value.

Compilation Complete.
(Batch::CopyOfMain_Paycode_Extraction)

Can somebody suggest me what is the right command to do that.

thanks

Re: Rename the txt file

Posted: Thu Dec 07, 2006 7:33 am
by ArndW
I am not sure of thet syntax of youe "mv" command, as it is not standard DOS. Try this:

Code: Select all

Call DSExecute ("NT", "move /ss/ppff":FileNameSuffix:".txt   "/dd/ppff":FileNameSuffix:".txt.bak" )

Posted: Thu Dec 07, 2006 7:39 am
by ray.wurlod
You've tried to use mv as a variable name. The command must be a single string - you must pass it as such.

Then, as Arnd noted, mv is not a Windows command; it is a UNIX command. Even if you're relying upon MKS Toolkit or some other UNIX emulator on Windows, you should use "SH" as the shell argument rather than "NT". "NT" is asking for the command to be executed in a DOS shell.

However, you have indicated that your server is a UNIX machine, so mv is the correct command, once the syntax is corrected. The Shell argument to DSExecute() must be "SH", not "NT".

Code: Select all

Call DSExecute("SH", "mv /ss/ppff" : FileNameSuffix : ".txt /dd/ppff" : FileNameSuffix : ".txt.bak", Output, ExitStatus)

Posted: Thu Dec 07, 2006 7:45 am
by ArndW
What struck me was "NT" as the shell, but the "MV" command in the original also had a keyword "TO"... quite odd. But posted in the UNIX bracket and using UNIX style paths, so most likely it is a UNIX command.

Posted: Thu Dec 07, 2006 8:12 am
by DSguru2B
To make things clearer and readable i would translate Ray's code as such:

Code: Select all

cmd = "mv /ss/ppff" : FileNameSuffix : ".txt /dd/ppff" : FileNameSuffix : ".txt.bak"
Call DSExecute("SH", cmd , Output, ExitStatus)

Posted: Thu Dec 07, 2006 8:59 am
by chulett
Why all the concentration on getting a Windows command? The post is marked as UNIX and the command is a UNIX command, so more than likely the 'NT' is the problem... in addition to what you posted regarding the syntax. So, how about:

Code: Select all

cmd = "mv /ss/ppff" : FileNameSuffix : ".txt /dd/ppff" : FileNameSuffix : ".txt.bak" 
Call DSExecute("UNIX", cmd , Output, ExitStatus)
The OP now has several choices. :wink:

Posted: Thu Dec 07, 2006 9:14 am
by ray.wurlod
The "to" in the original command was also problematic.