Summary of issues needing attention in unix/linux environment programming

Source: Internet
Author: User

There are several issues to be aware of when programming under Unix/linux (especially in the IDE or programming tools running on Windows):

1. Capitalization issues.

In the naming rules of a file or directory, pay particular attention to the case-sensitivity of the hump-naming method. There are also internal variables or references in some languages.

2. Permissions issues.

Do not manipulate the file system arbitrarily, in other words, do not move any files that are not related to you (Unix/linux everything is a file), especially if you want to see the permissions first when you create a new file in a new deployment or application

3. Re-emphasis on UNIX file encoding issues

When developing an IDE or programming tool running on Windows, it is important to note that you must convert the DOS file format (file format) to the UNIX file format when you save the file.

A line break in the DOS file format is \ r \ n

The UNIX file format has a line break of \ n

Now that vim and awk are improved, they can be automatically identified, and grep is not very well recognized, so a tool like grep can lead to unknown consequences.

Attached: Some tests for file format:

#!/bin/bash    #chkconfig: 345 86 14      #description:  startup and shutdown script for chatterserver ( Port: $SERVICEPORT))      #SERVICEPORT =29093     #SERVICEPORT = ' grep ^ port $ (PWD)/. /conf/constant.properties | awk -f  ' = '   ' {print $2} '      portfile=$ (PWD)/. /conf/constant.properties     #SERVICEPORT =$ (cat  $PORTFILE  | grep ^port  | awk -F  ' = '   ' {print $2} '     serviceport=$ (cat $ Portfile | dos2unix | grep ^port)     echo  "success:  Chatterserver (Port: $SERVICEPORT)  is ok "

The FileFormat of the above constant.properties file if it is DOS, as shown in:
650) this.width=650; "title=" 2015-07-14_172206 "style=" border-top:0px;border-right:0px;border-bottom:0px; border-left:0px; "border=" 0 "alt=" 2015-07-14_172206 "src=" http://s3.51cto.com/wyfs02/M02/6F/B0/ Wkiom1wk6jpd4ybjaaavfa8sblc766.jpg "height="/>

Then it will appear

650) this.width=650; "title=" 2015-07-14_164347 "style=" border-top:0px;border-right:0px;border-bottom:0px; border-left:0px; "border=" 0 "alt=" 2015-07-14_164347 "src=" http://s3.51cto.com/wyfs02/M00/6F/AD/ Wkiol1wk6mytj0cnaagk_q3ovcq673.jpg "height="/>

Another test script:

Cat >./portfile<<eof port=1080 EOF pidfile=./portfile cat $PIDFILE #SERVICEPORT =$ (grep ^port $PORTF ILE | Awk-f ' = ' {print $} ') #grep ^port $PORTFILE | Awk-f ' = ' {print $} ' # VS cat $PIDFILE | grep ^port |  Awk-f ' = ' {print $} ' serviceport=$ (cat $PIDFILE | grep ^port | awk-f ' = ' {print $} ') echo $SERVICEPORT Echo "Success:chatterserver (Port: $SERVICEPORT) is OK"

For the above file format problem, you can use the IDE or the file editor to handle, such as the settings shown:

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "http://s3.51cto.com/wyfs02/M02/6F/B0/wKiom1Wk6JPjReBAAABoEiW_VBA174.jpg" height= "117" />

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;border-bottom:0px;border-left:0px; " Border= "0" alt= "image" Src= "http://s3.51cto.com/wyfs02/M00/6F/B0/wKiom1Wk6JShdIgdAACd7MCXGeg559.jpg" height= "148" />

It can also be converted using Vim's: Set Ff=unix, or it can be converted with a tool such as Dos2unix, as shown in the following script:

# Note: $ (PWD)/... /conf/constant.properties file FileFormat must be UNIX not dos in shell scripts, or would cause some unknown error # NOTE : grep is Vrey sensitive to Dos FileFormat or UNIX fileformat # Apt-get install Dos2unix portfile=$ (PWD)/. /conf/constant.properties serviceport=$ (cat $PORTFILE | dos2unix | grep ^port | awk-f ' = ' {print $} ')

--end--

This article is from "Communication, My Favorites" blog, please make sure to keep this source http://dgd2010.blog.51cto.com/1539422/1674199

Summary of issues needing attention in unix/linux environment programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.