I'm sad to have to say this, but this sounds like homework. Homework is forbidden here, as there is a special forum for it, with special rules in place. Furthermore, this seems to deal with a DOS/Windows problem for which there is also another forum.
As you have undertaken a serious effort to solve your problem yourself and shown it i will make an exception to the rule ad answer, but PLEASE DO NOT TAKE THIS AS AN INVITATION to further stretch the rules.
out.txt
Quote:
Originally Posted by ilugopal
you see the second append go in the same line.I need to print the second append to go in the next line.
The reason for this behavior is not your script but your input file: you omitted the last linefeed after the end-of-file marker. Open your file "first.txt", got to the end of the line and press <ENTER>, then save the file. You will notice that your script will now work.
Here is some explanation: a file consists not only of readable ("printable" - which means also printable to the screen) characters and blanks, but also special characters used to transport some steering information. One of these special characters (or character combinations) is the "EOF", the "end-of-file"-marker, which has to be at the end of every file. In Unix this is a "^D" (CTRL-D) character, in DOS, Windows (and, historically, in CP/M) this is a "^Z" (CTRL-Z). See this reference for more information. The same is the case for the end of a line: Your computer has to somehow discern between
and
and this is done by inserting a special character which does exactly that. In DOS/Windows this is in fact a character combination, "CR/LF" ("Carriage Return", followed by a "Line Feed") with the hex codes "0D 0A". In Unix this is simply a "Line feed" character (hex "0A").
Btw: This difference is why there is a "binary" and a "text" mode in ftp: "text mode" would mean to translate "0D0A" to "0A" when transferring a file from a Unix system to/from a DOS system, "binary mode" means to not do this translation.
However, if you would display your file "first.txt" including these non-printable characters (use a hex-editor or "od" on a Unix-system) you would see:
When you "type" that two time into another file, the following happens: first the EOF character is removed, then the remainder is copied to the empty output file, then a EOF character is appended to the output. Then the second file is read, the EOF character of it is removed, text is appended to the output file and an EOF character is appended again. By now you have what you got with your script.
If the file would have contained an EOL character it would now contain "text<EOL>text<EOL><EOF>" and this would look like your desired output.
I did a search and found lots of questions/comments about how a dos script could execute Unix but not the other way round. If it's possible, I'd like the link to a post/site that would show me the way.
Thanks. (4 Replies)
Hi!
I'm very sorry for such simple and silly question but I cannot answer it by myself.
Can you please help me?
In .bat file I should run the C program which is in other directory, and the input configuration file is in this directory too.
This dir name is in dirRun variable. The... (3 Replies)
Hi all,
I am a very new user for korn scripting and in a process of learning.
i have a .bat file that calls a .vbs file which calls a macro used to convert an excel spread sheet to .csv file...
Now i want to automate this process. I want to call this bat file using a korn script or a korn... (6 Replies)
hi
I need to rediret an content of one file and append it to another file. I need it in .bat script. I tried this,
first.txt
I love to write script
type first.txt >> out.txt
type first.txt >> out.txt
out.txt
I love to write scriptI love to write script
you see the... (6 Replies)
Hi ,
I have a bat file on windows machine ,I need to excute it from my local unix machine using sambe utility.Is there any comman to execute the .bat file remotely.
Using samba utility i can post files to and fro from windows to unix but i don't comman to exute the .bat file.
can any one... (2 Replies)
I have serverfiles of same game. and there are bat files. I wont to run this on debian.
The files are difficult, eg
:########################################################################
:# File name: server_start.bat
:# Edited Last By: Mike Gleaves (ric)
:# V 1.0 1-10-2008
:# Comment:... (5 Replies)
I need to put/get files from Windows machine to Unix machine and vice-versa.
I wrote a text file "ftp1.txt" as below.
naga
naga06
cd /root/Naga
prom off
get time.unl
bye
I wrote another bat file "ftp.bat" as below.
ftp -n -s:C:\Users\Naga\Desktop\ftp1.txt IP_ADDRESS
but... (2 Replies)
First off, let me apologize if I'm posting this in the wrong place!
I am a newbie to this forum, to shell scripting and to Linux so please bare with me.
I created a script on the windows environment that makes a call to a java application and extracts a return value from the java app. It... (7 Replies)
Can someone translate this code to .bat for me? I have no clue.
#!/bin/sh
WAS_HOME="/opt/websphere/appserver/profiles/AppSrv01"
WAS_APP_SERVER="server1"
WAS_PROFILE_NAME="AppSrv01"
echo "Stopping App Server"
"${WAS_HOME}/bin/stopServer.sh" -profileName $WAS_PROFILE_NAME $WAS_APP_SERVER... (1 Reply)