Sponsored Content
Top Forums Shell Programming and Scripting Unable to generate Ctrl M at end of rec Post 302864287 by app1mvf on Wednesday 16th of October 2013 08:36:01 AM
Old 10-16-2013
Unable to generate Ctrl M at end of rec

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:
Code:
DLMT1='^M'
echo “${Value1}${Value2)${DLMT1} >> ${filepath}${linuxfile}.tmp

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:
Code:
DLMT1='^K'
echo “${Value1}${Value2)${DLMT1} >> /tmp/tempfile.txt

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:
Code:
DLMT1='^K'
echo “${Value1}${Value2)${DLMT1} >> /tmp/tempfile.txt
tr '\013-\015' ' ' <${filepath}${linuxfile}.tmp >${filepath}${linuxfile}.tmp2

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?
 

10 More Discussions You Might Find Interesting

1. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

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)
Discussion started by: wtofu
6 Replies

2. Shell Programming and Scripting

Ctrl-M at end of each line

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)
Discussion started by: navi
3 Replies

3. Programming

unable to get end of file while reading HTTP data from socket

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)
Discussion started by: Harish.joshi
2 Replies

4. Shell Programming and Scripting

Generate quarter dates with begin date and end date

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)
Discussion started by: sol_nov
9 Replies

5. Shell Programming and Scripting

Ctrl-C or Ctrl-Z causing exit the session

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)
Discussion started by: jramesh1
2 Replies

6. Shell Programming and Scripting

Generate Codes based on start and End values of numbers in a column

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)
Discussion started by: canimba
5 Replies

7. Shell Programming and Scripting

How to handle CTRL+Z or CTRL+C in shells script?

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)
Discussion started by: ckchelladurai
3 Replies

8. Shell Programming and Scripting

Unable to set end of line in mail command

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)
Discussion started by: rogerben
5 Replies

9. UNIX for Dummies Questions & Answers

Ctrl-V + Ctrl-J for newline character does not work inside vi editor

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)
Discussion started by: royalibrahim
1 Replies

10. Shell Programming and Scripting

Automation of keyboard inputs..like Ctrl+d and Ctrl+a

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)
Discussion started by: chandana hs
2 Replies
CTYPE_CNTRL(3)								 1							    CTYPE_CNTRL(3)

ctype_cntrl - Check for control character(s)

SYNOPSIS
bool ctype_cntrl (string $text) DESCRIPTION
Checks if all of the characters in the provided string, $text, are control characters. Control characters are e.g. line feed, tab, escape. PARAMETERS
o $text - The tested string. RETURN VALUES
Returns TRUE if every character in $text is a control character from the current locale, FALSE otherwise. EXAMPLES
Example #1 A ctype_cntrl(3) example <?php $strings = array('string1' => " ", 'string2' => 'arf12'); foreach ($strings as $name => $testcase) { if (ctype_cntrl($testcase)) { echo "The string '$name' consists of all control characters. "; } else { echo "The string '$name' does not consist of all control characters. "; } } ?> The above example will output: The string 'string1' consists of all control characters. The string 'string2' does not consist of all control characters. NOTES
Note If an integer between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative val- ues have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string contain- ing the decimal digits of the integer. SEE ALSO
ctype_print(3). PHP Documentation Group CTYPE_CNTRL(3)
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy