Using name of transfered file to set as parameter on a Batch

All questions about Control-M jobs definitions
Post Reply
User avatar
osafr71
Nouveau
Nouveau
Posts: 26
Joined: 21 Jan 2010 12:00

Using name of transfered file to set as parameter on a Batch

Post by osafr71 » 02 Oct 2012 12:32

Hi there,

Onde again i need the help of somebody. I need to transfer a file with AFT and use the name of that file to set as a Parameter when executing a batch file. Can i do that?

Ex: Transfer file xpto.txt

Job file = import_file.bat xpto.txt

Regards,

Osafr71

User avatar
ThePirate
Nouveau
Nouveau
Posts: 61
Joined: 04 Feb 2008 12:00
Location: Cleveland, OH

Post by ThePirate » 08 Oct 2012 6:21

Using AFT 7.0 you need to set up the transfer as a file watcher and on the Advanced->File Watcher tab set the field Auto-Edit containg detected file name: %%xptoFileName. Then on your batch job following the AFT job, on the command line you pass the paraeter (import_file.bat %%xptoFileName).

User avatar
osafr71
Nouveau
Nouveau
Posts: 26
Joined: 21 Jan 2010 12:00

Post by osafr71 » 09 Oct 2012 4:16

Hi.

Ok, i only have AFT 6.4, but soon i will have the 7.0.

Thanks

User avatar
ThePirate
Nouveau
Nouveau
Posts: 61
Joined: 04 Feb 2008 12:00
Location: Cleveland, OH

Post by ThePirate » 09 Oct 2012 4:46

AFT 6.4 may have this feature. I actually pass the parameter as

Command Line: import_file.bat %%1

and define the xptoFileName varible on the Set tab as

%1 = %%xptoFileName

User avatar
mauriziog
Nouveau
Nouveau
Posts: 807
Joined: 08 Jun 2007 12:00
Location: Varese - Italy
Contact:

Post by mauriziog » 26 Oct 2012 11:40

you can pass a varaible from one job to other:
- define a global variable in set panel of the first job:
%%\GLobalVarName=Value

When this jobs run sets the value to the GobalVarName, and all the following jobs can use it sibmply writing:

%%GobalVarName.

In your case the second job has in the general tab the path and the file name of the script you may lauch.
In this second job set pnale write:
PARM1=%%GlobalVarName

And you pass the "Value" as the first parameter of the script.
In the script you has the "Value" in the %1 parameter (in batch).
So for example in the script you can have:

set FileName=%1

Post Reply