Rename the txt file

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
Poonam Singh
Participant
Posts: 5
Joined: Wed Aug 16, 2006 10:58 am

Rename the txt file

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Re: Rename the txt file

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

Post 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)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

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

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The "to" in the original command was also problematic.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply