Link to home
Start Free TrialLog in
Avatar of iceb
icebFlag for Canada

asked on

MSDOS Batch File / The system cannot find the file specified / Error Mesage

I am using MSDOS.
Ver Command brings this up.
Microsoft Windows XP [Version 5.1.2600]

I am running a batch file named main.bat. If i browse to the folder and run the main.bat , it works correctly.

If i use an external software it returns me an error:
The system cannot find the file specified.
In my application i need to use the external software.

Can you please recommend why is this error showing up and how can i fix it ?

The contents of the main.bat file are below:
script  1.11.111.111 <input1.script >output1.xls
script  1.11.111.111 <input2.script >output2.xls
script  1.11.111.111 <input3.script >output3.xls
script  1.11.111.111 <input4.script >output4.xls
script  1.11.111.111 <input5.script >output5.xls
script  1.11.111.111 <input6.script >output6.xls
script  1.11.111.111 <input7.script >output7.xls
script  1.11.111.111 <input8.script >output8.xls
script  1.11.111.111 <input9.script >output9.xls

"script" is a proprietary script that reads data from input1.script file, writes the data to the device with ip address 1.11.111.111 and then reads from the device and outputs to the output1.xls and so on.
error2.jpg
software.jpg
Avatar of sirbounty
sirbounty
Flag of United States of America image

Specify the full path for script...
You could shorten it with

For /l %%a in (1,1,9) do (
  c:\pathToScript\Script 1.11.111.111 < c:\pathOfInput\input%%a.script > c:\pathToOutput\output%%a.xls
)
Optionally, you could cd to the path in your script as well...

@echo off
cd \ "C:\Path To Files"

For /l %%a in (1,1,9) do (
  Script 1.11.111.111 < input%%a.script > output%%a.xls
)
Avatar of iceb

ASKER

Sir Bounty

The complete path is given below
D:\SimcoeTests\Plus16x\delete\PosWatthrVarhrB\OneMinute\main.bat
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iceb

ASKER

Sir bounty.

Thanks for all the above info. I tried all three. The first two worked. Great Help !  Then i put these main.bat files in c drive just to make sure it works and it worked !

The third code from Line 17 to line 21 did not work.

Can you please take a look at the above and see what might be wrong with this code ?
The above method is great when the input file names and output file names are in a sequence.

Question 1. But in few scripts i have the input with 9 or more different names and output with equally 9 or more different names.

What shall i do in those cases ? I am asuming that i just need to use this once in those cases.

cd /d D:\SimcoeTests\Plus16x\delete\PosWatthrVarhrB\OneMinute\

and it should work.

Question 2. This is a very good method but when if i copy it to a different folder or computer then i need to change the path name in each and every file. The entire purpose of automation was one point start to finish. This is not a big setback but is there a way i could update the folder path automatically. e.g i copied it to folder D:\new. It updates to that path in the main.bat file.
Sorry mate - my brain is already half-frizzled for the day....so my apologies in advance:

If the first 2 work - you're wanting to get the 3rd one working - why?  Just for curiousity?
What it 'should' do (the 3rd one) is append that to a temporary path environment.  Problem is that it would be a volatile environment and wouldn't remain for any subsequent calls.  Another option though would be to either manually add that to your system-wide path, or automate it through code (but this would be a bit more work for something so simple).

That said, add some troubleshooting steps in there, such as:
@echo off
set Path=%path%;D:\SimcoeTests\Plus16x\delete\PosWatthrVarhrB\OneMinute\
Echo.  Your path is now: %path%
pause
REM If the above is not showing the OneMinute path, then something is wrong...
For /l %%a in (1,1,9) do (
  Script 1.11.111.111 < input%%a.script > output%%a.xls
)

Now for my ignorance...
Question 1: - I don't follow at all - what do you mean here?  If you're simply saying that some may be 10,11,12, etc - just increment that 9 in the (1,1,9) block.

Question 2 - I didn't get either.  You can move a file anywhere you like if you hard code the path, but of course, it requires updating each time you relocate it (if you have any supporting/dependencies in the new folder).
Avatar of iceb

ASKER

I just wanted to make the third one t olearn something.  Just by asking that question i learnt how to troubleshoot whihc i would have missed.

My apologies for not making it clear earlier.

script  1.11.111.111 <moscow.script >russia.xls
script  1.11.111.111 <beijing.script >china.xls
script  1.11.111.111 <usa.script >newyork.xls
script  1.11.111.111 <sirbounty.script >expertsexchnage.xls

I just meant to say that the input and the output filenames can be different. in that case i should add one line to themain.bat file:e..g
cd /d D:\SimcoeTests\Plus16x\delete\PosWatthrVarhrB\OneMinute\


Let us forget the Question 2. I can live this.
Ah...I think I see (and it's not you, really - it's me - haha...lack of sleep, long story...)

You can create other loops - I was just suggesting the 'counting' loop to meet your initial requirements.
For /l performs a loop (1,1,9) - starting at #1, incrementing 1 each loop, and ending at #9.

Just as easily, you can choose to go this route:

for /f "tokens=1,2" %%a in (moscow russia beijing china newyork usa) do call :process %%a %%b
and then in process routine, you'd be able to reference moscow as %1 and russia as %2 (paramters).

All depends on what you're aim is...try a for /? from the command line to get a help text on it.
And as stated in your other thread - you could also develop a file to correlate between input and output parameters to use...
Avatar of iceb

ASKER

Sir bounty

Lack of Sleep. Long hours at Work. Same story here. I have learnt more today than in any other day. I guess i can simplify some of my work with your above suggestions. I tried debugging with that command you told me before. This is what i got.

 Your path is now: c:\program files\ca\dcs\dmscripting\;c:\program files\ca\dcs\cawin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;c:\program files\ca\unicenter software delivery\bin;c:\ca_appsw;C:\Program Files\MATLAB\R2006b\bin;C:\Program Files\MATLAB\R2006b\bin\win32;;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;c:\sqlany50\win32;D:\SimcoeTests\Plus16x\delete\PosWatthrVarhrB\OneMinute\
The system cannot find the file specified.

I got the error again. I dont know why is this happening. Do you think the software might be doing something ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of iceb

ASKER

Sir Bounty

I will test this on Monday. I choose not to go to work on Saturday. I was very tired and i needed this break. The weather was nice though thunderstorms were there.

Thank you very much for your reply. I really appreciate your support. We will touch base on monday. I hope i am able to get this working.

Avatar of iceb

ASKER

Thanks sir bounty. With your help i was able to write the correct scripts. However i am not able to execute the scripts with the external software. I keep on getting the error "The system cannot find the file specified". I think since my original question was answered this question should be closed. I will create another question for the problem.
Glad I could lend a helping hand here.  Thanx much for the grade.
Good luck! :^)