LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-02-2005, 04:05 AM   #1
jollyjoice
Member
 
Registered: Aug 2003
Location: UK
Distribution: Gentoo 64
Posts: 383

Rep: Reputation: 30
Angry 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)
 
Old 11-02-2005, 04:56 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Did you try :
Code:
type c:\code.txt >> htmlfile.htm
(set the correct path to code.txt file)
 
Old 11-02-2005, 11:41 AM   #3
jollyjoice
Member
 
Registered: Aug 2003
Location: UK
Distribution: Gentoo 64
Posts: 383

Original Poster
Rep: Reputation: 30
no... will try it thanks.
 
Old 11-02-2005, 01:12 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
Old 11-02-2005, 02:36 PM   #5
jollyjoice
Member
 
Registered: Aug 2003
Location: UK
Distribution: Gentoo 64
Posts: 383

Original Poster
Rep: Reputation: 30
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...
 
Old 11-02-2005, 02:53 PM   #6
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
.bat files on Linux? dave1.1 Linux - Newbie 5 10-21-2004 07:15 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM
modifying files with "echo" stakhous Linux - Newbie 9 06-22-2004 03:18 PM
"batch files" in red hat, similar to .bat files in dos shycalais Linux - Newbie 2 10-12-2003 08:34 AM
Echo /devPrinting doesn't work, echo /usb/lp0 works, Testpage works, Printing doesn't Hegemon Linux - General 3 08-15-2002 01:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration