LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   echo bat files HELP (https://www.linuxquestions.org/questions/programming-9/echo-bat-files-help-379201/)

jollyjoice 11-02-2005 04:05 AM

echo bat files HELP
 
Ok, first off I am in windows, and have to use Bat files. There is no other way around this so please don't offer this "help".

I need to echo some java code into the end of a html file, but when I run the .bat file it exits before completion. I guess this is because it is trying to execute the code, not just echo it.
The only way I have found for the file to run is to put ""s around the code, this is obviously useless as it is then not parsed when the html file is loaded.

Another idea was to put the code in a txt file then echo the content of that file, which I cannot get to work as it just places "code.txt" not its contents.

Please bear in mind that it took me 10 mins of googling to find that >> appends... KISS pls!

This is what I have so far, it works but then the html doesn't...

Code:

echo "lots of java stuff here" >> htmlfile.htm
pause (to see if it worked :D)


keefaz 11-02-2005 04:56 AM

Did you try :
Code:

type c:\code.txt >> htmlfile.htm
(set the correct path to code.txt file)

jollyjoice 11-02-2005 11:41 AM

no... will try it :D thanks.

paulsm4 11-02-2005 01:12 PM

Please remember: just because you're in Windows, it doesn't necessarily mean that you *have* to use .bat files. Alternatives you might be able to consider include:

1. Perl is freely available for Windows.

Please consider ActivePerl (for example):
http://www.activeperl.com/

2. All versions of Windows NT 4.0 and higher (including XP, Win2k, SBA Server 2003, etc etc) include "Windows Scripting Host":

http://tiger.la.asu.edu/WSH/wsh_tutorial.htm
http://msdn.microsoft.com/archive/de...RunCscript.asp
http://msdn.microsoft.com/library/de...scriptinga.asp
http://msdn.microsoft.com/archive/de...utorialTOC.asp

3. Since it sounds like you're already on a web server (a Microsoft/IIS web server), perhaps your best best is to forget about doing it "from Windows" and instead consider "doing it from IIS".

That is, write an ASP (.asp) or ASP.Net (.aspx) script instead of a .bat file:
http://www.stardeveloper.com/article...0041601&page=1

4. Finally, if you decide you *must* use .bat files, everything you need to know (everything there *IS* to know!) about .bat file syntax can easily be learned in about 15 minutes:
http://www.computerhope.com/batch.htm

'Hope that helps .. PSM

jollyjoice 11-02-2005 02:36 PM

the basics are that we need to add on some code to a html file to make it display properly in the site, but the html file is produced using excel weekly (or more often) and the person doing this is not keen on the idea of having to open the file in, say, notepad, then adding in the code.
My programming knowledge isn't that great and time is limited. We need it to be as simple as possible. To be able to just click on a bat, or anything for that matter, that will "just do it" is what we need. I shall have a look at those other options, but we can't be installing stuff and CMD is blocked by the admin, so anything needing this has to be in a bat as far as I know...

paulsm4 11-02-2005 02:53 PM

Cool - that suggests yet another - perhaps, for your situation, ideal - alternative:

5) Use an Excel macro to add the boilerplate HTML to your Excel file:
http://www.pcworld.com/howto/article/0,aid,15849,00.asp
http://www.angelfire.com/biz7/julian...ans_macros.htm
http://office.microsoft.com/en-us/as...072101033.aspx

'Hope that helps .. PSM

NOTE:
An "Excel macro" is written in VBScript, a dialect that includes most/all of MS-Access, MS Word, ASP 3.0 (for web servers), WSH (for the Windows command line), etc etc. So any Wisdom you gain in solving this problem on Excel is directly applicable to anything you might wish to do on these other environments.


All times are GMT -5. The time now is 06:10 AM.