Hello, I was wondering if someone can assist me. I have a file that I download from a mainframe to a RedHat Linux 5.5 server, the file is delimited by control underscore characters and the record is terminated by a control M (carriage return). The problem I am having is with the control M character; in my shell script I read the file in and write out a new tweaked file. The new file that I create I am able to create the control underscore but I am not able create the control M on the file.... It just disappears from the file. (Just so people are aware.... I am aware that a control M is created in vi with a Ctrl-V Ctrl-M)
So far I have tried the following:
1) I set a variable to control M
Example:
The above writes out the values of Value1 and Value2 but the Control M isn't written out
2) I set a variable to control K
Example:
The above writes out the values of Value1, Value2 and the Control K - That Works
3) I set a variable to control K then tried to replace the control K with control m using tr
Example:
Didn't work.... Control M disappears....
Now I have tried a bunch of other things but I am still not able to get a control M at the end of the record.... Let me be very clear the issue is getting the control M at the end of the record.... In my testing I am able to get a control M to appear in the middle of the record but that's not what I want. Does anyone have any ideas?
I suggest that you share your script's code (along with your operating system and shell version), a sample of the input data, a sample of the erroneous output that your script generates, and, finally, the desired output. Since non-graphic characters are crucial here, make sure to post octal/hex dumps of the input/output, so that there is no ambiguity about what we're seeing.
To generate a ^M in a shell script is trivial:
If that doesn't work, I'm inclined to believe that the problem lies elsewhere.
On an unrelated note, your tr attempt does not convert from one control character to another. It selects a range of them and converts them to spaces, so, naturally, they "disappear".
Hello, I was wondering if someone can assist me. I have a file that I download from a mainframe to a RedHat Linux 5.5 server, the file is delimited by control underscore characters and the record is terminated by a control M (carriage return). The problem I am having is with the control M character; in my shell script I read the file in and write out a new tweaked file. The new file that I create I am able to create the control underscore but I am not able create the control M on the file.... It just disappears from the file. (Just so people are aware.... I am aware that a control M is created in vi with a Ctrl-V Ctrl-M)
So far I have tried the following:
1) I set a variable to control M
Example:
The above writes out the values of Value1 and Value2 but the Control M isn't written out
2) I set a variable to control K
Example:
The above writes out the values of Value1, Value2 and the Control K - That Works
3) I set a variable to control K then tried to replace the control K with control m using tr
Example:
Didn't work.... Control M disappears....
Now I have tried a bunch of other things but I am still not able to get a control M at the end of the record.... Let me be very clear the issue is getting the control M at the end of the record.... In my testing I am able to get a control M to appear in the middle of the record but that's not what I want. Does anyone have any ideas?
There are a few problems with the command:
that appears in all three of your scripts.
First, it looks like you want a double qouted string, but the closing regular double quote at the end of the string and you have specified the opening double quote character rather than a regular double quote character that would be recognized by the shells to surround a string.
Second, you have ${...) instead of ${...}. You have to match the opening brace character with a closing brace character, not a closing parenthesis character.
Both of these will cause all three of the shell scripts you showed us to produce diagnostics like:
or:
depending on what shell you're using.
If you change the above line in all three of your scripts to:
you will probably get what you wanted. (Although the in your third script you also need to change the control-K to control-M when you define DLMT1.)
Hi..!
I'm stuck with my automation of starting a process and keeping it running even after the current ssh session has exited..
So i'm trying to use command 'screen'. which is doing exactly what i wanted, But the problem is automation of the same.
i will have to press Ctrl+a and Ctrl+d for... (2 Replies)
Hi friends,
I am trying to add a newline char ('\n') between the query and the commit statement in the following shell script.
#! /bin/sh
echo "select * from tab; commit;" > data.sql
I have tried typing in "Ctrl-V + Ctrl-J" combination which has inserted ^@ (NUL) character but the commit... (1 Reply)
Hi ,
Am trying to send mail using the mail command, but the mail command is working but its not sending automatically after pressing .(dot) in the command prompt it sends . How to achieve that. Also it showing the below line after pressing the dot .
/home/abc1/dead.letter... Saved message in... (5 Replies)
Hi,
while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder.
How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Hello All,
Could you please help with this.
This is what I have:
506234.222 2
506234.222 2
506234.222 2
506234.222 2
508212.200 2
508212.200 2
333456.111 2
333456.111 2
333456.111 2
333456.111 2
But this is what I want:
506234.222 1
506234.222 2
506234.222 2
506234.222 3 (5 Replies)
H! I have written script where it need to invoke the perl script in background, then write the pid in temp file then bring back the job to foreground. whenever the Ctrl-C or Ctrl-Z is pressed in the script has to exit and prompt should be dispalyed. but this script causing exit from shell session... (2 Replies)
Hi All,
I am trying to generate quarter dates with user giving input as begin date and end date. Example: Input by user:
begin_date = "2009-01-01"
end_date = 2010-04-30"
required output:
2009-01-01 2009-03-31 09Q01
2009-04-01 2009-06-30 09Q02
.
.
till
2010-01-01 2010-03-31 10Q01
... (9 Replies)
I am trying to read HTTP data from a socket. However, for the final set of data being read using read(), read blocks and the control doesnt come back for further processing. I tried using select, but it didn't work...
Any help would be greatly acknowledged.:) (2 Replies)
I have a write a script in VI editor.whenever i open the Vi script ,it is showing ctrl-M at the end of each line.
Please tell me how to remove this Ctrl-M from each line.
Thanks in Advance (3 Replies)
I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)