Use mono for development on Mac OS-log synchronization (2)

Source: Internet
Author: User

In the previous article, we used mono for development on Mac OS-synchronous log (1) describes how to read configuration files and write logs on Mac OS. The basic configuration is complete. The following is the focus.

Due to the time relationship, the source code is not analyzed. The source code is provided at the end.

I. Installation

Step 1: Install the mono framework. You can download it from the mono official website. Note there is a problem with MonoFramework-MRE-2.10.5_0.macos10.xamarin.x86.dmg running on earlier Mac OS. Install the MonoFramework-MRE-2.10.4_0.macos10.xamarin.x86.dmg file.

Step 2: Execute the program. Copy the executable "monitoringapp" to the desktop and double-click it.

Note: The monitoringapp script is generated after compilation in Mono's development tool monodevelop. Open it in notepad and you will find the following code:

#! /Bin/sh

Exec mono "/users/production/desktop/APP/lib/monitoringapp/monitoringapp.exe" "$ @"

Through this applescript, we can see that Mono is used in MAC compaction. This applescript runs through a terminal, causing the following troubles:

1) write the dead path. For example, if I move the monitoringapp file to a location, it cannot be run because the path in this script is dead. Of course, you can learn applescript, and then search for the monitoringapp.exe file and execute it. However, it is obviously impossible for me to have only three days.

2) unable to run without the terminal. However, the program started by applescript cannot run without the terminal. For example, if you shut down the terminal, OK, and your program is shut down. I had not solved this problem at the time, but now I want to solve it, but I have no Apple Computer to test it.

II. Environment Configuration

Step 1: configure the configuration file. The configuration file name is configuration.txt ". This directory provides a reference file. The parameters are described as follows:
Monitoringdirectorytype: Directory type. Only two values (immediate and cycle) are supported ). Immediate indicates real-time monitoring (default), and cycle indicates periodic monitoring.
Path: monitor directory path. Must be an existing path.
Targetpath: target directory path. It can be a remote directory path. The SMB path cannot be used, but it should be of the "/volumes/mes_data/n81a" type.
Includesubdirectories: Indicates whether to include subdirectories.
Filter: Filter strings. For example, "*" indicates monitoring all files, and "*. txt" indicates monitoring all text files.
Backuppath: backup path.
Backupexpired: Backup expiration time. The Unit is day. Must be an integer. The default value is 30 days.
Cycleminutes: Cycle cycle time. Unit: Minute. Must be an integer. The default value is 60 minutes.
Note:
1) Eight configurations are indispensable. All configurations and write values are required.
2) multiple directories are supported. However, all values must be expressed in multiple forms. For example, "['immediate', 'cycle']" indicates two directories, and two values must be specified for other configuration items.
3) All symbols must be English characters. The value must be enclosed in single quotes.
4) Some values only work for Certain types. For example, cycleminutes only works for directories whose monitoringdirectorytype is cycle. Therefore, when the directory type is immediate, the value is invalid.
5) The configuration name ends with a colon. The Configuration value is enclosed in brackets.
6) do not wrap a line before configuring each configuration item. Line feed between each configuration item. The program reads configuration items by row.
7) the configuration name and value are case insensitive.

After the configuration file is configured, copy the file to the root directory of the System user. For example, "/users/nzocnzoc ".

Note: in fact, the above are all dumbys. You should read the code by yourself. It is worth noting that it is best to use English for all your texts; otherwise, the copies may be garbled in the past, even if the language is set to Chinese.

Step 2: Configure boot. Please drag the program into the Login Items of the corresponding user first. For details, choose System Preferences> accounts> Login Items )]. Connect to the remote server. For specific configuration, go to> connect to server. Remember the password (remember ). After the configuration is complete, drag the target directory to the target user's logon item so that the remote directory can be automatically connected at startup.
Note: Due to the relatively slow network connection or Wi-Fi connection, please try to move the location of the remote directory in the logon item so that you can buffer the time. No way. This is a tough method, but it is always a function that enables startup and connects to a remote directory.
Step 3: restart the computer and test whether the computer is successful. Be sure to test whether the file can be uploaded to a remote directory.

Iii. problem diagnosis.

If the file is not successfully uploaded and the program does not provide an exception prompt, please refer to the error log in the data directory under the "/users/current user" path.

 

 

 

Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

In fact, this project code is very simple. It can be written in less than one day, but the problem is transplanted to Mac OS. Many times, we all say mono can be used across platforms. In fact, it is also possible, but there are many problems.

  1. The code must all be in English, including comments. Otherwise, garbled characters may occur during porting.
  2. Monodevelop (Mono Development Tool) must be used for compilation and generation on Mac OS.
  3. The Mac file system is very different from the window system. When the. NET code is used to obtain the path, such as the program startup path, it cannot be obtained.
  4. Mono for Mac OS does not support console applications. It is best to use GTK # To draw the Window application interface. Otherwise, the interface may be displayed incorrectly. To hide the interface, it is best to set the width and height to 0, and the setting attributes and methods are invalid. I don't know if the next version will fix it.
  5. Pay attention to the mono Framework version. It is possible that the latest version does not support some code or some earlier versions of the Apple system.

Here, I want to share my experience with you if you have used mono for Mac OS.

Download the source code: monitoringapp.7z

 

 

Related Article

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.