Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 09-28-2009, 07:32 AM   #1 (permalink)
Registered User
 
Join Date: May 2009
Posts: 18
OS: Windows 2005


Pencil script to print text without new line character

Hi i have a requirement to re-direct the list of DOS commands into a text file with a blank space inbetween them
eg:
echo "Y:\Drive\tar" > test.txt
echo "-cf test.tar" >> test.txt
echo "*.xml" >> test.txt

so i need to print Y:\Drive\tar -cf test.tar *.xml in test.txt

Instead its getting printed as
Y:\Drive\tar
-cf test.tar
*.xml

after printing the command pass the line as an input to the command prompt and i should execute that line.

Kindly help me in doing this.
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 09-28-2009, 10:00 PM   #2 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7


Re: script to print text without new line character

You can't. Echo will output a CR/LF after each line.
The quotes will be echoed, so don't include them unless they are really needed, like around a file name.
Just Echo the three parts all on one line:
Code:
>test.txt Echo "Y:\Drive\tar" -cf test.tar *.xml
Copy test.txt test.bat
Call test.bat
Del Test.bat
Or set it as a variable:
Code:
Set _CmdLine="Y:\Drive\tar" -cf test.tar *.xml
>test.txt Echo.%_CmdLine%
%_CmdLine%
Or after echoing each part, read the file in, combine the lines, and output it back to the file:
Code:
>test.txt Echo "Y:\Drive\tar"
>>test.txt Echo -cf test.tar
>>test.txt Echo *.xml
SetLocal EnableDelayedExpansion
Set _CmdLine=
For /F "Tokens=1 Delims=" %%I In ('Type Test.txt') Do Set _CmdLine=!_CmdLine! %%I
Set _CmdLine=%_CmdLine:~1%
>test.txt Echo %_CmdLine%
%_CmdLine%
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers; I just don't always match the answers to the right questions.
Rated R for Violence -- When your PC flies through a window, that's violent, right?

Last edited by TheOutcaste; 09-28-2009 at 10:01 PM.
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-09-2009, 12:56 AM   #3 (permalink)
Registered User
 
Join Date: May 2009
Posts: 18
OS: Windows 2005


Re: script to print text without new line character

Hey thank you so much! its working great!!!
I need one more help too....
I have few lines in my test.txt file (which was echo from the DOS command) like

Y:\Drive\tar
DW_Bank*.xml
DW_Bank.tar
DW_Day*.xml
DW_Day.tar
DW_Daily.xml
DW_Daily.tar

I want this to be
Y:\Drive\tar DW_Bank*.xml DW_Bank.tar
Y:\Drive\tar DW_Day*.xml DW_Day.tar
Y:\Drive\tar DW_Daily*.xml DW_Daily.tar

Is this possible?
Need your help in this regard!!
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 10-10-2009, 04:33 PM   #4 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7


Re: script to print text without new line character

Unless there is a fixed pattern to these lines, it would be nearly impossible to write a script. and unless there are hundreds of lines, probably faster to just edit by hand, using Notepad++ or Notetab Light, where you can search for lines containing only Y:\Drive\tar, then easily combine them with a few clicks/key presses.

Is it always Y:\Drive\tar followed by 3 pairs of lines you need to combine as you show?
Or is it actually like this:
Y:\Drive\tar
DW_Bank*.xml
DW_Bank.tar
Y:\Drive\tar
DW_Day*.xml
DW_Day.tar
Y:\Drive\tar
DW_Daily.xml
DW_Daily.tar

Does there happen to be a space (or multiple spaces) after Y:\Drive\tar?
If some have none, some have one, some have more, you have to allow for that. If none of the file names or paths have spaces, it would be easier, but if any have spaces that gets complicated real quick.
__________________
Microsoft MVP - Windows Desktop Experience
Of course I know all the answers; I just don't always match the answers to the right questions.
Rated R for Violence -- When your PC flies through a window, that's violent, right?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 11:59 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85