# Batch File - Passing To Another Command Line



## Scottcom4 (Apr 30, 2012)

Hi Everybody.

I am attempting to execute a Command Line Interface for a scheduling software called JAMS, execute the relevant processes and then exit (see attatched code) all within a batch file.

I came up with the following but simply can't get the JAMS CLI to populate from SET SERVER ********4001 onwards. I know the rest of the script executes once I manually exit the JAMS CLI (inclusive of the SET SERVER ********4001) so I assume the JAMS CLI isn't being passed the remainder of the batch.

Does anyone know of a way to achieve this? I don't expect that a huge number of people will have used JAMS, but any information relating to similar issues would be greatly recieved.

Thank you for your help.


```
REM @ECHO OFF
SET OUTPUTLOCATION = [URL="file://*********/any/old/directory"]\\*********\any\old\directory[/URL]
SET /P JOB   = "PLEASE ENTER THE PREFIX OF THE JOBS YOU WISH TO MIGRATE!!!  
SET /P SETUP = PLEASE ENTER THE NAME OF THE SETUP YOU WISH TO MIGRATE!!!
"C:\PROGRAM FILES\MVPSI\JAMS\CLIENT\JAMS.EXE"
SET SERVER ********4001
EXPORT SETUP %SETUP% /OUTPUT="%OUTPUTLOCATION%\SETUP_%SETUP%.XML" /SYSTEM=BI_DEV
EXPORT JOB %JOB%* /OUTPUT="%OUTPUTLOCATION%\JOB_%SETUP%.XML" /SYSTEM=BI_DEV
 
SUBMIT MIGRATION /JOB
EXIT
```


----------



## Squashman (Apr 4, 2003)

Command line arguments that are used with an executable are usually predefined within the program and they usually require you to use a switch with the value of the switch after that. Your batch file cannot directly interact with another executable that requires input or requires you to type in input after it is executed.

Your SET SERVER statement will error out. That is not a properly formatted command. You are missing an equals sign

So if your program was designed to take command line arguments it may look something like this.

JAMS.EXE /Job=%JOB5 /Setup=%Setup% /server=MyServer4001


----------



## Scottcom4 (Apr 30, 2012)

Hi Squash,

Thank you for your reply.

I am not sure if I explained what I am attempting to do properly.

"C:\PROGRAM FILES\MVPSI\JAMS\CLIENT\JAMS.EXE" executes the JAMS Command Line.
set server myserver4001 is then entered into the JAMS command line to create a connection to the server we wish to execute jobs on.

Are you suggesting that if I use this syntax:

set stuff = "set server myserver4001"
"C:\PROGRAM FILES\MVPSI\JAMS\CLIENT\JAMS.EXE" /stuff=%stuff%

To parse the arguments from the batch file to the JAMS CLI I would execute the set server myserver4001 statement?

I tried to get this to work, but to no avail.

Thank you again for your thoughts.

Regards,
Scott


----------



## Squashman (Apr 4, 2003)

As I said, you will not be able to have the batch file interact directly with another executable. If you want to automate the execution the program would need to support command line arguments.

I assume this is what you are using.
http://www.jamsscheduler.com/doc/GettingStarted/GettingStarted.html
You may be better off doing this in PowerShell since it has a cmdlet.
http://www.jamsscheduler.com/doc/GettingStarted/JAMSCommandline.html

You be better of helping yourself on this as about all anyone is going to be able to tell you is to read the documentation for JAMS.


----------



## Scottcom4 (Apr 30, 2012)

Hi Squash,

Thank you again.

The problem is that Powershell is not installed on our machines and there is no chance of having this installed.

I have also been down the path of the Jams CLI documentation. Unfortunately this is a single page with 5 lines of text and an image. All of which are less than helpful. 

I can't believe that there isn't a way to execute this in WCL. I guess I will just create a text document template and then copy and paste the entire thing into WCL when I want it to run, which is effectively what I am doing already.

Thank you again for your help.

Regards
Scott


----------



## Squashman (Apr 4, 2003)

So you are still on XP because Powershell is native to Vista and Windows 7. It looks like the perfect solution to your problem.
http://www.jamsscheduler.com/PowerShell.aspx


----------



## Scottcom4 (Apr 30, 2012)

Exactly.

I use powershell on our Windows Server 2008 box, but these scripts need to be executed on our local machines and since we only have XP I am basically screwed.


----------



## Squashman (Apr 4, 2003)

I know this may look quirky but have you tried this.


```
"C:\Program Files\MVPSI\JAMS\Client\JAMS.EXE" SET SERVER Servername
"C:\Program Files\MVPSI\JAMS\Client\JAMS.EXE" EXPORT SETUP %SETUP% /OUTPUT="%OUTPUTLOCATION%\SETUP_%SETUP%.XML" /SYSTEM=BI_DEV
"C:\Program Files\MVPSI\JAMS\Client\JAMS.EXE" EXPORT JOB %JOB%* /OUTPUT="%OUTPUTLOCATION%\JOB_%SETUP%.XML" /SYSTEM=BI_DEV
"C:\Program Files\MVPSI\JAMS\Client\JAMS.EXE" SUBMIT MIGRATION /JOB
```


----------



## Squashman (Apr 4, 2003)

So why won't they install powershell on you xp machines.


----------



## Scottcom4 (Apr 30, 2012)

Hi Squashman,

I have tried the approach you listed above and it doesn't work unfortunately. You need to set the server everytime you invoke JAMS session, so all I get is a series of errors when the second command attempts to execute.

I am not sure why we can't have powershell on our machines, unfortunately no means no, so I am stuck with what I have to work with.

Thank you again for all your help.


----------



## Squashman (Apr 4, 2003)

Scottcom4 said:


> You need to set the server everytime you invoke JAMS session,


That is strange because from what I read on their website you can set the server just like I showed you above and you don't need to set it again as long as you have that cmd prompt session open.


----------

