- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Carriage Return in perl scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2010 06:18 PM
тАО12-19-2010 06:18 PM
Carriage Return in perl scripts
How come? I assumed that linux follows the unix convention where each line is terminated by line feed. Where does the carriage return come from?
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2010 07:11 PM
тАО12-19-2010 07:11 PM
Re: Carriage Return in perl scripts
dos2ux myscript.dos > myscript.perl
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2010 11:33 PM
тАО12-19-2010 11:33 PM
Re: Carriage Return in perl scripts
> from?
If my psychic powers were not so pathetically
weak, then I might be able to determine
whence this file ("perl script") came, and
that might provide a clue as to the reasons
for its line endings being what they are.
(Whatever they are.)
> [...] and noticed ^M on every line.
Noticed how? How did the lines end on the
original file (before the transfer)?
> I used scp [...]
As usual, showing actual commands with their
actual output can be more helpful than vague
descriptions or interpretations.
> [...] linux [...]
uname -a
ssh -V
> [...] HP-UX [...]
uname -a
ssh -V
Even a few basic facts might help more than
approximately none.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2010 04:38 AM
тАО12-20-2010 04:38 AM
Re: Carriage Return in perl scripts
As Bill noted, Windows (and a few other platforms) delimit lines in text files with a carriage-return/linefeed combination (CRLF) as opposed to UNIX's simple linefeed (LF). There is nothing here that is special/indigenous to the fact that you are dealing with a Perl script.
A common mistake is to FTP a file in binary mode from a Windows to UNIX server. In this case, like 'scp', any carriage return characters are transferred intact. If you use FTP's ASCII mode, carriage-return characters will be added or subtracted to match the receiving platform's standard.
A good survery of the climate can be found here:
http://en.wikipedia.org/wiki/Newline
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2010 04:51 AM
тАО12-20-2010 04:51 AM
Re: Carriage Return in perl scripts
By the way, aside from using 'dos2ux' on your HP platform you could (of course) do:
# perl -pi.old -e 's/\r$//' file
...which will strip carriage returns from the CRLF pairs, updating your file (script or whatever) in-place and retaining an original file copy as "*.old".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2010 08:05 AM
тАО12-20-2010 08:05 AM
Re: Carriage Return in perl scripts
I think I made a mistake.
the file on the linux machine and the HP-UX machine are identical
and the file on the HP-UX machine does not have ^M in it
I just did scp from the linux to HP-UX, back to linux and then back to HP-UX, still no ^M
here's the script if you're curious
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2010 10:31 AM
тАО12-20-2010 10:31 AM
Re: Carriage Return in perl scripts
Bill Hassell, sysadmin