Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summary of the problems that must be paid attention to in programming in UNIX/Linux environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

There are a few things you must pay attention to when programming under UNIX/Linux (especially when developing with IDE or programming tools running on Windows):

1. Case issues.

In the naming rules of files or directories, special attention should be paid to the case sensitivity of hump naming. The same is true of internal variables or references in some languages.

two。 Permission issue.

Do not manipulate the file system arbitrarily, in other words, do not touch any files that have nothing to do with you (everything under UNIX/Linux is files), especially if you want to generate new files in a new deployment or application, check the permissions first.

3. Re-emphasis on the coding of unix files

In the development of IDE or programming tools running on Windows, be sure to convert the dos file format (file format) to unix file format when saving files.

The newline character in the dos file format is\ r\ n

The newline character in unix file format is\ n

Now vim and awk have improved on this, which can be recognized automatically, but grep can not recognize it very well, so once using a tool like grep, it will 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"

If the fileformat of the above constant.properties file is dos, as shown in the following figure:

It will appear.

Another test script:

Cat >. / portfile

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report