Problems encountered during use of linux Pipelines
This is the first time I have published a blog on ChinaUnix. I hope you can share more with me in the future!
Go to the topic:
Today, I encountered a pitfall:
Call the conf_del method in the server_function file in the script to delete the configuration file.
Then, in the directory where the script is deleted
The conf_del method is as follows:
Function conf_del {
Cnt_EV = 'grep "export EVSERVER_RUNTIME" $1 | wc-l'
Cnt_QT = 'grep "export QT_PLUGIN_PATH" $1 | wc-l'
Cnt_Flum = 'grep "export FLUME_HOME" $1 | wc-l'
[[$ Cnt_EV-eq 1] & sed-I "/export EVSERVER_RUNTIME/d" $1
[[$ Cnt_QT-eq 1] & sed-I "/export QT_PLUGIN_PATH/d" $1
[[$ Cnt_Flum-eq 1] & sed-I "/export FLUME_HOME/d" $1
}
To put it bluntly, some information in the. bashrc file is deleted.
Because I tested other functions today, the deletion information in the. bashrc file does not exist.
Therefore:
[[$ Cnt_EV-eq 1] & sed-I "/export EVSERVER_RUNTIME/d" $1
[[$ Cnt_QT-eq 1] & sed-I "/export QT_PLUGIN_PATH/d" $1
[[$ Cnt_Flum-eq 1] & sed-I "/export FLUME_HOME/d" $1
This place has a cup.
The script returns only:
[[0-eq 1]
[[0-eq 1]
[[0-eq 1]
Then, the operation to delete the directory where the script is located is no longer performed.
After checking and testing, we found that the problem should be caused by the Linux pipeline.
The conf_del method cannot be exited because [[0-eq 1]
Solution: append a sentence in the conf_del method.
Function conf_del {
Cnt_EV = 'grep "export EVSERVER_RUNTIME" $1 | wc-l'
Cnt_QT = 'grep "export QT_PLUGIN_PATH" $1 | wc-l'
Cnt_Flum = 'grep "export FLUME_HOME" $1 | wc-l'
[[$ Cnt_EV-eq 1] & sed-I "/export EVSERVER_RUNTIME/d" $1
[[$ Cnt_QT-eq 1] & sed-I "/export QT_PLUGIN_PATH/d" $1
[[$ Cnt_Flum-eq 1] & sed-I "/export FLUME_HOME/d" $1
Echo "all informations have been deleted! "
}
Then, the steps for deleting directories in the main script can be continued.
Note: I do not quite understand why this problem occurs. I hope you will have a chat with me. Thank you!