I have a text file in which some lines aren't formatted the same way as the others. To be more precise: In this type of lines, fields are written on 9 characters, whereas on the other lines, fields are 7 characters length. Format of a (misformatted) line being:
1st field on 40 characters, then 4 spaces, then 1 character (field named note, for example letter 'a', space ' ' or letter 'b'), then 4 spaces. The preceding sequence 4 spaces+1 character+4 spaces (example below) being repeated a number of times:
a
Such a line would for example be:
a a a a a c b a a a a a
Due to the specificity of these lines, I get an offset between lines:
26 26 26 26 26 26 26 26 26 26 26
a a a a a c b a a a a
I would like to get rid of 2 unwanted spaces, so that on my line, a field would become 7 characters wide, as in others:
1st field on 40 characters, then 3 spaces, then 1 character (field named note, for example letter 'a'), then 3 spaces.
I can "find" such a line using the regex find in Notepad++:
Find what : ^ {40}(( {4})(?<note>.)( {4}))+
But how do I replace all utterances of the 4 spaces+1 character+4 spaces by 3 spaces+1 character+3 spaces, so that fields on every line have the same length?
The desired format, after substitution, would for example be:
26 26 26 26 26 26 26 26 26 26 26
a a a a a c b a a a a
Here is a larger extract of the offset file:
20/03/2018
H0917 26_LAV 0 Semaine 2 En service le 04 Septembre 2017 - TAD Partiel 11/07/2017 16:09 H0917
Vertical Notes
Montferrier-sur-Lez - Cirad de Baillargu Montferrier-sur-Lez - Cirad de Baillarguet
Montpellier Occitanie Montpellier Occitanie
26 Occitanie - Montferrier-sur-Lez 26 Montferrier-sur-Lez - Cirad de BaillarguMontpellier Occitanie Montferrier-sur-Lez - Cirad de Baillarguet
########## VOYAGES
0 Semaine Montferrier-sur-Lez - Cirad de Baillarguet
26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26
a a a a a c b a a a a a a a a a a
Occitanie 6:50 7:20 7:50 8:20 8:50 9:30 10:10 10:40 11:10 11:40 12:10 12:10 12:40 13:10 13:40 14:10 14:40 15:10 15:40 16:10 16:40 17:10 17:40 18:10 18:40 19:10 19:40 20:10 20:40
Lycée Frédéric Bazille 6:58 7:28 7:58 8:28 8:58 9:37 10:17 10:47 11:17 11:47 12:17 12:17 12:47 13:17 13:47 14:18 14:48 15:18 15:48 16:18 16:49 17:19 17:49 18:19 18:49 19:18 19:47 20:17 20:47
La Lironde 7:02 7:32 8:02 8:35 9:05 9:42 10:22 10:52 11:22 11:52 12:23 12:23 12:52 13:22 13:52 14:23 14:53 15:23 15:53 16:23 16:56 17:26 17:56 18:26 18:56 19:23 19:52 20:22 20:52
Chemin Neuf 7:07 7:37 8:07 8:40 9:10 9:47 10:27 10:57 11:27 11:57 12:28 12:28 12:57 13:27 13:57 14:28 14:58 15:28 15:58 16:28 17:01 17:31 18:01 18:31 19:01 19:28 19:57 20:27 20:57
La Grand Font 7:08 7:38 8:08 8:41 9:11 9:48 10:28 10:58 11:28 11:58 12:29 12:29 12:58 13:28 13:58 14:29 14:59 15:29 15:59 16:29 17:02 17:32 18:02 18:32 19:02 19:29 19:58 20:28 20:58
Picadou 7:09 7:39 8:09 8:42 9:12 9:49 10:29 10:59 11:29 11:59 12:30 12:30 12:59 13:29 13:59 14:30 15:00 15:30 16:00 16:30 17:03 17:33 18:03 18:33 19:03 19:30 19:59 20:29 20:59
Distillerie 7:11 7:41 8:11 8:44 9:14 9:51 10:31 11:01 11:31 12:01 12:32 12:32 13:01 13:31 14:01 14:32 15:02 15:32 16:02 16:32 17:05 17:35 18:05 18:35 19:05 19:32 20:01 20:31 21:01
Cirad de Baillarguet 7:14 7:44 8:14 8:47 9:17 9:54 10:34 11:04 11:34 12:04 12:35 12:35 13:04 13:34 14:04 14:35 15:05 15:35 16:05 16:35 17:08 17:38 18:08 18:38 19:08 19:35 20:04 20:34 21:04
Correct file should be:
20/03/2018
H0917 26_LAV 0 Semaine 2 En service le 04 Septembre 2017 - TAD Partiel 11/07/2017 16:09 H0917
Vertical Notes
Montferrier-sur-Lez - Cirad de Baillargu Montferrier-sur-Lez - Cirad de Baillarguet
Montpellier Occitanie Montpellier Occitanie
26 Occitanie - Montferrier-sur-Lez 26 Montferrier-sur-Lez - Cirad de BaillarguMontpellier Occitanie Montferrier-sur-Lez - Cirad de Baillarguet
########## VOYAGES
0 Semaine Montferrier-sur-Lez - Cirad de Baillarguet
26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26 26
a a a a a c b a a a a a a a a a a
Occitanie 6:50 7:20 7:50 8:20 8:50 9:30 10:10 10:40 11:10 11:40 12:10 12:10 12:40 13:10 13:40 14:10 14:40 15:10 15:40 16:10 16:40 17:10 17:40 18:10 18:40 19:10 19:40 20:10 20:40
Lycée Frédéric Bazille 6:58 7:28 7:58 8:28 8:58 9:37 10:17 10:47 11:17 11:47 12:17 12:17 12:47 13:17 13:47 14:18 14:48 15:18 15:48 16:18 16:49 17:19 17:49 18:19 18:49 19:18 19:47 20:17 20:47
La Lironde 7:02 7:32 8:02 8:35 9:05 9:42 10:22 10:52 11:22 11:52 12:23 12:23 12:52 13:22 13:52 14:23 14:53 15:23 15:53 16:23 16:56 17:26 17:56 18:26 18:56 19:23 19:52 20:22 20:52
Chemin Neuf 7:07 7:37 8:07 8:40 9:10 9:47 10:27 10:57 11:27 11:57 12:28 12:28 12:57 13:27 13:57 14:28 14:58 15:28 15:58 16:28 17:01 17:31 18:01 18:31 19:01 19:28 19:57 20:27 20:57
La Grand Font 7:08 7:38 8:08 8:41 9:11 9:48 10:28 10:58 11:28 11:58 12:29 12:29 12:58 13:28 13:58 14:29 14:59 15:29 15:59 16:29 17:02 17:32 18:02 18:32 19:02 19:29 19:58 20:28 20:58
Picadou 7:09 7:39 8:09 8:42 9:12 9:49 10:29 10:59 11:29 11:59 12:30 12:30 12:59 13:29 13:59 14:30 15:00 15:30 16:00 16:30 17:03 17:33 18:03 18:33 19:03 19:30 19:59 20:29 20:59
Distillerie 7:11 7:41 8:11 8:44 9:14 9:51 10:31 11:01 11:31 12:01 12:32 12:32 13:01 13:31 14:01 14:32 15:02 15:32 16:02 16:32 17:05 17:35 18:05 18:35 19:05 19:32 20:01 20:31 21:01
Cirad de Baillarguet 7:14 7:44 8:14 8:47 9:17 9:54 10:34 11:04 11:34 12:04 12:35 12:35 13:04 13:34 14:04 14:35 15:05 15:35 16:05 16:35 17:08 17:38 18:08 18:38 19:08 19:35 20:04 20:34 21:04
Thanks for helping,
Julien
Your question is a bit unclear, but this got things aligned for me:
([^ ])
\1
Note there is one space before and one after the parenthesis. This removes one space before and one after each single non-space character. It ignores the 26s since those are two non-space characters, so replace all works.
Related
I have a C++ project that uses CMake that I then use to generate ninja projects that build without issues. I tried to generate an Xcode project but when I try to build it I get an error saying .o files cannot be found:
clang: error: no such file or directory: '/Users/ruihpacheco/chi/databaseclient/build_xcode/src/databaseclient.build/Debug/databaseclient.build/Objects-normal/x86_64/connection.o'
clang: error: no such file or directory: '/Users/ruihpacheco/chi/databaseclient/build_xcode/src/databaseclient.build/Debug/databaseclient.build/Objects-normal/x86_64/utils.o'
clang: error: no such file or directory: '/Users/ruihpacheco/chi/databaseclient/build_xcode/src/databaseclient.build/Debug/databaseclient.build/Objects-normal/x86_64/state_machines.o'
clang: error: no such file or directory: '/Users/ruihpacheco/chi/databaseclient/build_xcode/src/databaseclient.build/Debug/databaseclient.build/Objects-normal/x86_64/parsers.o'
clang: error: no such file or directory: '/Users/ruihpacheco/chi/databaseclient/build_xcode/src/databaseclient.build/Debug/databaseclient.build/Objects-normal/x86_64/generators.o'
Checking the directory shows that these files seem to exist but with different names:
> la src/databaseclient.build/Debug/databaseclient.build/Objects-normal/x86_64/ Thu Jan 24 15:14:07 2019
total 23536
drwxr-xr-x 63 ruihpacheco staff 2.0K Jan 24 15:14 .
drwxr-xr-x 4 ruihpacheco staff 128B Jan 24 15:14 ..
-rw-r--r-- 1 ruihpacheco staff 37K Jan 24 15:14 abstract_connection.d
-rw-r--r-- 1 ruihpacheco staff 825K Jan 24 15:14 abstract_connection.dia
-rw-r--r-- 1 ruihpacheco staff 883K Jan 24 15:14 abstract_connection.o
-rw-r--r-- 1 ruihpacheco staff 662B Jan 24 15:14 abstract_result.d
-rw-r--r-- 1 ruihpacheco staff 6.8K Jan 24 15:14 abstract_result.dia
-rw-r--r-- 1 ruihpacheco staff 232K Jan 24 15:14 abstract_result.o
-rw-r--r-- 1 ruihpacheco staff 37K Jan 24 15:14 connection-4F0435C11320AC72.d
-rw-r--r-- 1 ruihpacheco staff 895K Jan 24 15:14 connection-4F0435C11320AC72.dia
-rw-r--r-- 1 ruihpacheco staff 610K Jan 24 15:14 connection-4F0435C11320AC72.o
-rw-r--r-- 1 ruihpacheco staff 151B Jan 24 15:14 connection-A95D7C1FAB89AE69.d
-rw-r--r-- 1 ruihpacheco staff 220B Jan 24 15:14 connection-A95D7C1FAB89AE69.dia
-rw-r--r-- 1 ruihpacheco staff 50K Jan 24 15:14 connection-A95D7C1FAB89AE69.o
-rw-r--r-- 1 ruihpacheco staff 37K Jan 24 15:14 connection-CC26C77ACFAB6964.d
-rw-r--r-- 1 ruihpacheco staff 912K Jan 24 15:14 connection-CC26C77ACFAB6964.dia
-rw-r--r-- 1 ruihpacheco staff 1.0M Jan 24 15:14 connection-CC26C77ACFAB6964.o
-rw-r--r-- 1 ruihpacheco staff 2.9K Jan 24 15:14 databaseclient.LinkFileList
-rw-r--r-- 1 ruihpacheco staff 230B Jan 24 15:14 error_code.d
-rw-r--r-- 1 ruihpacheco staff 220B Jan 24 15:14 error_code.dia
-rw-r--r-- 1 ruihpacheco staff 71K Jan 24 15:14 error_code.o
-rw-r--r-- 1 ruihpacheco staff 828B Jan 24 15:14 generators-2BF46CDAE4191A6E.d
-rw-r--r-- 1 ruihpacheco staff 8.5K Jan 24 15:14 generators-2BF46CDAE4191A6E.dia
-rw-r--r-- 1 ruihpacheco staff 218K Jan 24 15:14 generators-2BF46CDAE4191A6E.o
-rw-r--r-- 1 ruihpacheco staff 548B Jan 24 15:14 generators-AB4B789D17316956.d
-rw-r--r-- 1 ruihpacheco staff 6.8K Jan 24 15:14 generators-AB4B789D17316956.dia
-rw-r--r-- 1 ruihpacheco staff 415K Jan 24 15:14 generators-AB4B789D17316956.o
-rw-r--r-- 1 ruihpacheco staff 36K Jan 24 15:14 listener.d
-rw-r--r-- 1 ruihpacheco staff 978K Jan 24 15:14 listener.dia
-rw-r--r-- 1 ruihpacheco staff 1.2M Jan 24 15:14 listener.o
-rw-r--r-- 1 ruihpacheco staff 132B Jan 24 15:14 md5.d
-rw-r--r-- 1 ruihpacheco staff 220B Jan 24 15:14 md5.dia
-rw-r--r-- 1 ruihpacheco staff 95K Jan 24 15:14 md5.o
-rw-r--r-- 1 ruihpacheco staff 673B Jan 24 15:14 parsers-404CED0A5A8A6B5B.d
-rw-r--r-- 1 ruihpacheco staff 6.7K Jan 24 15:14 parsers-404CED0A5A8A6B5B.dia
-rw-r--r-- 1 ruihpacheco staff 320K Jan 24 15:14 parsers-404CED0A5A8A6B5B.o
-rw-r--r-- 1 ruihpacheco staff 666B Jan 24 15:14 parsers-704FC03E3B6B0880.d
-rw-r--r-- 1 ruihpacheco staff 6.4K Jan 24 15:14 parsers-704FC03E3B6B0880.dia
-rw-r--r-- 1 ruihpacheco staff 501K Jan 24 15:14 parsers-704FC03E3B6B0880.o
-rw-r--r-- 1 ruihpacheco staff 222B Jan 24 15:14 result.d
-rw-r--r-- 1 ruihpacheco staff 220B Jan 24 15:14 result.dia
-rw-r--r-- 1 ruihpacheco staff 53K Jan 24 15:14 result.o
-rw-r--r-- 1 ruihpacheco staff 134B Jan 24 15:14 sha1.d
-rw-r--r-- 1 ruihpacheco staff 648B Jan 24 15:14 sha1.dia
-rw-r--r-- 1 ruihpacheco staff 82K Jan 24 15:14 sha1.o
-rw-r--r-- 1 ruihpacheco staff 149B Jan 24 15:14 sql_state.d
-rw-r--r-- 1 ruihpacheco staff 220B Jan 24 15:14 sql_state.dia
-rw-r--r-- 1 ruihpacheco staff 94K Jan 24 15:14 sql_state.o
-rw-r--r-- 1 ruihpacheco staff 903B Jan 24 15:14 state_machines-286E024B50293C5A.d
-rw-r--r-- 1 ruihpacheco staff 7.0K Jan 24 15:14 state_machines-286E024B50293C5A.dia
-rw-r--r-- 1 ruihpacheco staff 357K Jan 24 15:14 state_machines-286E024B50293C5A.o
-rw-r--r-- 1 ruihpacheco staff 482B Jan 24 15:14 state_machines-79E86DDB3D33788F.d
-rw-r--r-- 1 ruihpacheco staff 6.1K Jan 24 15:14 state_machines-79E86DDB3D33788F.dia
-rw-r--r-- 1 ruihpacheco staff 200K Jan 24 15:14 state_machines-79E86DDB3D33788F.o
-rw-r--r-- 1 ruihpacheco staff 313B Jan 24 15:14 utils-8D3E37120512868D.d
-rw-r--r-- 1 ruihpacheco staff 5.5K Jan 24 15:14 utils-8D3E37120512868D.dia
-rw-r--r-- 1 ruihpacheco staff 86K Jan 24 15:14 utils-8D3E37120512868D.o
-rw-r--r-- 1 ruihpacheco staff 523B Jan 24 15:14 utils-A68FF56E16A77975.d
-rw-r--r-- 1 ruihpacheco staff 7.4K Jan 24 15:14 utils-A68FF56E16A77975.dia
-rw-r--r-- 1 ruihpacheco staff 113K Jan 24 15:14 utils-A68FF56E16A77975.o
-rw-r--r-- 1 ruihpacheco staff 420B Jan 24 15:14 utils-C6A6E2A9DFE20FA6.d
-rw-r--r-- 1 ruihpacheco staff 5.8K Jan 24 15:14 utils-C6A6E2A9DFE20FA6.dia
-rw-r--r-- 1 ruihpacheco staff 223K Jan 24 15:14 utils-C6A6E2A9DFE20FA6.o
This seems to be an issue with Xcode as my project has several classes called connection, generators, parsers, state_machines and utils but defined in different namespaces.
Main CMakeLists.txt:
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt.")
endif (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif (CCACHE_PROGRAM)
project(databaseclient LANGUAGES CXX VERSION 0.1.0.0 DESCRIPTION)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE DEBUG)
endif(NOT CMAKE_BUILD_TYPE)
add_subdirectory(src)
add_library(${PROJECT_NAME}_shared SHARED $<TARGET_OBJECTS:${PROJECT_NAME}>)
add_library(${PROJECT_NAME}_static STATIC $<TARGET_OBJECTS:${PROJECT_NAME}>)
# Added here so we can run ctest from the root directory of the project.
enable_testing()
add_subdirectory(tests)
CMakeLists.txt under src/:
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
set(
INCLUDES
${PROJECT_SOURCE_DIR}/include/databaseclient/parameters.hpp
${PROJECT_SOURCE_DIR}/include/databaseclient/connection.hpp
${PROJECT_SOURCE_DIR}/include/databaseclient/sql_state.hpp
${PROJECT_SOURCE_DIR}/include/databaseclient/collation.hpp
${PROJECT_SOURCE_DIR}/include/databaseclient/error_code.hpp
${PROJECT_SOURCE_DIR}/include/databaseclient/result.hpp
)
set(
MAIN
${PROJECT_SOURCE_DIR}/src/connection.cpp
${PROJECT_SOURCE_DIR}/src/sql_state.cpp
${PROJECT_SOURCE_DIR}/src/result.cpp
)
set(
DETAIL
${PROJECT_SOURCE_DIR}/src/detail/types.hpp
${PROJECT_SOURCE_DIR}/src/detail/listener.hpp
${PROJECT_SOURCE_DIR}/src/detail/listener.cpp
${PROJECT_SOURCE_DIR}/src/detail/error_code.hpp
${PROJECT_SOURCE_DIR}/src/detail/error_code.cpp
${PROJECT_SOURCE_DIR}/src/detail/md5.hpp
${PROJECT_SOURCE_DIR}/src/detail/md5.cpp
${PROJECT_SOURCE_DIR}/src/detail/sha1.hpp
${PROJECT_SOURCE_DIR}/src/detail/sha1.cpp
${PROJECT_SOURCE_DIR}/src/detail/utils.hpp
${PROJECT_SOURCE_DIR}/src/detail/utils.cpp
${PROJECT_SOURCE_DIR}/src/detail/abstract_result.hpp
${PROJECT_SOURCE_DIR}/src/detail/abstract_result.cpp
${PROJECT_SOURCE_DIR}/src/detail/abstract_connection.hpp
${PROJECT_SOURCE_DIR}/src/detail/abstract_connection.cpp
)
set(
PG
${PROJECT_SOURCE_DIR}/src/detail/pg/connection.cpp
${PROJECT_SOURCE_DIR}/src/detail/pg/connection.hpp
${PROJECT_SOURCE_DIR}/src/detail/pg/utils.hpp
${PROJECT_SOURCE_DIR}/src/detail/pg/utils.cpp
${PROJECT_SOURCE_DIR}/src/detail/pg/state_machines.hpp
${PROJECT_SOURCE_DIR}/src/detail/pg/state_machines.cpp
${PROJECT_SOURCE_DIR}/src/detail/pg/parsers.hpp
${PROJECT_SOURCE_DIR}/src/detail/pg/parsers.cpp
${PROJECT_SOURCE_DIR}/src/detail/pg/generators.hpp
${PROJECT_SOURCE_DIR}/src/detail/pg/generators.cpp
)
set(
MDB
${PROJECT_SOURCE_DIR}/src/detail/mdb/connection.cpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/connection.hpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/utils.hpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/utils.cpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/state_machines.hpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/state_machines.cpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/parsers.hpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/parsers.cpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/generators.hpp
${PROJECT_SOURCE_DIR}/src/detail/mdb/generators.cpp
)
source_group(
"include"
FILES
${INCLUDES}
)
source_group(
""
FILES
${MAIN}
)
source_group(
"detail"
FILES
${DETAIL}
)
source_group(
"detail\\pg"
FILES
${PG}
)
source_group(
"detail\\mdb"
FILES
${MDB}
)
add_library(
${PROJECT_NAME}
OBJECT
${INCLUDES}
${MAIN}
${DETAIL}
${PG}
${MDB}
)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
VERSION ${PROJECT_VERSION}
POSITION_INDEPENDENT_CODE ON
)
target_compile_features(
${PROJECT_NAME}
PUBLIC
cxx_std_11
cxx_auto_type
cxx_constexpr
cxx_deleted_functions
cxx_inline_namespaces
cxx_lambdas
cxx_noexcept
cxx_nullptr
cxx_override
cxx_range_for
)
target_compile_definitions(
${PROJECT_NAME}
PRIVATE
ASIO_STANDALONE=1
ASIO_NO_EXCEPTIONS=1
ASIO_NO_DEPRECATED=1
)
target_include_directories(
${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/include/
PRIVATE
${byte-lite_SOURCE_DIR}/include/nonstd
${asio_SOURCE_DIR}/asio/include/
)
if (UNIX)
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
target_compile_options(${PROJECT_NAME} PRIVATE -g)
endif (CMAKE_BUILD_TYPE MATCHES DEBUG)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wundefined-func-template -Weverything -ferror-limit=0 -fcolor-diagnostics -Wno-c++98-compat -Wno-documentation -Wno-c++98-compat-pedantic -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors)
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
# -O1 -fno-optimize-sibling-calls -Wthread-safety -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fsanitize=address
target_compile_options(${PROJECT_NAME} PRIVATE -glldb -D_FORTIFY_SOURCE=2)
endif (CMAKE_BUILD_TYPE MATCHES DEBUG)
endif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_compile_definitions(${PROJECT_NAME} PRIVATE _GLIBCXX_USE_C99 _GLIBCXX_USE_C99_MATH _GLIBCXX_USE_C99_MATH_TR1)
target_compile_options(${PROJECT_NAME} PRIVATE -lstdc++ -rpath=/usr/local/lib/gcc48)
endif (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
endif (UNIX)
I fixed this by removing the OBJECT target and just creating a static library.
I'm trying to create a service using systemctl on my CentOS 7 server.
In /usr/lib/systemd/system I've this situation ...
[root#centos-4gb-hel1-1 system]# pwd
/usr/lib/systemd/system
[root#centos-4gb-hel1-1 system]# ls -la getUpdatesTelegram.sh
-rwxr-xr-x. 1 root root 116 Oct 24 22:32 getUpdatesTelegram.sh
[root#centos-4gb-hel1-1 system]# cat getUpdatesTelegram.sh
#!/bin/bash
while true ; do
/var/www/html/OpenProntoSoccorsi/TelegramBot/getUpdates_launcher.sh
sleep 5
done
[root#centos-4gb-hel1-1 system]#
If I try to execute
/var/www/html/OpenProntoSoccorsi/TelegramBot/getUpdates_launcher.sh
all works fine.
In /etc/systemd/system I've this ....
[root#centos-4gb-hel1-1 system]# cd /etc/systemd/system
[root#centos-4gb-hel1-1 system]# ls -la
total 40
drwxr-xr-x. 10 root root 4096 Oct 24 22:05 .
drwxr-xr-x. 4 root root 4096 Oct 18 22:41 ..
drwxr-xr-x. 2 root root 4096 Sep 24 12:31 basic.target.wants
lrwxrwxrwx. 1 root root 37 Sep 24 12:29 default.target -> /lib/systemd/system/multi-user.target
drwxr-xr-x. 2 root root 4096 Sep 24 12:26 default.target.wants
drwxr-xr-x. 2 root root 4096 Sep 24 12:27 dev-virtio\x2dports-org.qemu.guest_agent.0.device.wants
drwxr-xr-x. 2 root root 4096 Sep 24 12:26 getty.target.wants
drwxr-xr-x. 2 root root 4096 Sep 24 12:31 local-fs.target.wants
drwxr-xr-x. 2 root root 4096 Oct 24 22:32 multi-user.target.wants
drwxr-xr-x. 2 root root 4096 Sep 24 12:31 sysinit.target.wants
drwxr-xr-x. 2 root root 4096 Sep 24 12:26 system-update.target.wants
[root#centos-4gb-hel1-1 system]# cd multi-user.target.wants/
[root#centos-4gb-hel1-1 multi-user.target.wants]# ls -la
total 8
drwxr-xr-x. 2 root root 4096 Oct 24 22:32 .
drwxr-xr-x. 10 root root 4096 Oct 24 22:05 ..
lrwxrwxrwx. 1 root root 38 Sep 24 12:27 auditd.service -> /usr/lib/systemd/system/auditd.service
lrwxrwxrwx. 1 root root 37 Sep 24 12:31 brandbot.path -> /usr/lib/systemd/system/brandbot.path
lrwxrwxrwx. 1 root root 39 Sep 24 12:27 chronyd.service -> /usr/lib/systemd/system/chronyd.service
lrwxrwxrwx. 1 root root 44 Sep 24 12:33 cloud-config.service -> /usr/lib/systemd/system/cloud-config.service
lrwxrwxrwx. 1 root root 43 Sep 24 12:33 cloud-final.service -> /usr/lib/systemd/system/cloud-final.service
lrwxrwxrwx. 1 root root 48 Sep 24 12:33 cloud-init-local.service -> /usr/lib/systemd/system/cloud-init-local.service
lrwxrwxrwx. 1 root root 42 Sep 24 12:33 cloud-init.service -> /usr/lib/systemd/system/cloud-init.service
lrwxrwxrwx. 1 root root 37 Sep 24 12:26 crond.service -> /usr/lib/systemd/system/crond.service
lrwxrwxrwx. 1 root root 50 Oct 24 22:32 getUpdatesTelegram.service -> /usr/lib/systemd/system/getUpdatesTelegram.service
lrwxrwxrwx. 1 root root 42 Sep 24 12:27 irqbalance.service -> /usr/lib/systemd/system/irqbalance.service
lrwxrwxrwx. 1 root root 37 Sep 24 12:29 kdump.service -> /usr/lib/systemd/system/kdump.service
lrwxrwxrwx. 1 root root 40 Sep 24 12:26 remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
lrwxrwxrwx. 1 root root 46 Sep 24 12:31 rhel-configure.service -> /usr/lib/systemd/system/rhel-configure.service
lrwxrwxrwx. 1 root root 39 Sep 24 12:26 rsyslog.service -> /usr/lib/systemd/system/rsyslog.service
lrwxrwxrwx. 1 root root 36 Sep 24 12:27 sshd.service -> /usr/lib/systemd/system/sshd.service
lrwxrwxrwx. 1 root root 37 Sep 24 12:26 tuned.service -> /usr/lib/systemd/system/tuned.service
[root#centos-4gb-hel1-1 multi-user.target.wants]# cat getUpdatesTelegram.service
[Service]
Type=simple
ExecStart=/bin/bash /bin/getUpdatesTelegram.sh
[Install]
WantedBy=multi-user.target
[root#centos-4gb-hel1-1 multi-user.target.wants]#
When I try to execute
systemctl enable getUpdatesTelegram.service
I obtain
...
...
getUpdatesTelegram.service loaded failed failed getUpdatesTelegram.service
...
...
The log I've is tthe follow ....
[root#centos-4gb-hel1-1 multi-user.target.wants]# journalctl -u getUpdatesTelegram.service
-- Logs begin at Fri 2018-10-19 20:09:02 CEST, end at Wed 2018-10-24 22:44:11 CEST. --
Oct 24 21:44:10 centos-4gb-hel1-1 systemd[1]: Started getUpdatesTelegram.service.
Oct 24 21:44:10 centos-4gb-hel1-1 systemd[1]: Starting getUpdatesTelegram.service...
Oct 24 21:44:10 centos-4gb-hel1-1 systemd[1]: getUpdatesTelegram.service: main process exited, code=exited, status=203/EXEC
Oct 24 21:44:10 centos-4gb-hel1-1 systemd[1]: Unit getUpdatesTelegram.service entered failed state.
Oct 24 21:44:10 centos-4gb-hel1-1 systemd[1]: getUpdatesTelegram.service failed.
Where I'm wrong?
Thank you in advance!
First, custom services should not be put in /usr/lib/systemd/system, but in /etc/systemd/system. Same goes with shell scripts, just put them into /usr/local/sbin or something.
The reason why this does not work is that the script path in your service file getUpdatesTelegram.service is wrong:
ExecStart=/bin/bash /bin/getUpdatesTelegram.sh
should really be
ExecStart=/bin/bash /usr/lib/systemd/system/getUpdatesTelegram.sh
(Though as I wrote, don't put shell scripts into /usr/lib/systemd/system)
As a Red Hat fork, CentOS tends to follow similar guidelines.
The Red Hat system administrator's guide offers this useful paragraph for your situation.
The solution proposed by Jakob is correct by the way.
I was building gstreamer latest version on my raspberry pi. I wanted to have python bindings, hence I installed gobject-introspection-1.0 and pygobject-3.18.2 before compiling the gstreamer and its plugins.
At the end of the build of gstreamer and all of its plugins, I see these files:
pi#raspberrypi:~/kurento $ ls -ltr /usr/local/lib/girepository-1.0
total 580
-rw-r--r-- 1 root staff 214076 Mar 28 19:28 Gst-1.5.typelib
-rw-r--r-- 1 root staff 43712 Mar 28 19:28 GstBase-1.5.typelib
-rw-r--r-- 1 root staff 6500 Mar 28 19:28 GstController-1.5.typelib
-rw-r--r-- 1 root staff 6272 Mar 28 19:28 GstNet-1.5.typelib
-rw-r--r-- 1 root staff 13116 Mar 28 19:29 GstCheck-1.5.typelib
-rw-r--r-- 1 root staff 14460 Mar 28 20:23 GstTag-1.5.typelib
-rw-r--r-- 1 root staff 2508 Mar 28 20:23 GstFft-1.5.typelib
-rw-r--r-- 1 root staff 27460 Mar 28 20:23 GstRtp-1.5.typelib
-rw-r--r-- 1 root staff 24160 Mar 28 20:23 GstSdp-1.5.typelib
-rw-r--r-- 1 root staff 32856 Mar 28 20:23 GstRtsp-1.5.typelib
-rw-r--r-- 1 root staff 75268 Mar 28 20:23 GstVideo-1.5.typelib
-rw-r--r-- 1 root staff 46800 Mar 28 20:24 GstAudio-1.5.typelib
-rw-r--r-- 1 root staff 25764 Mar 28 20:24 GstPbutils-1.5.typelib
-rw-r--r-- 1 root staff 5732 Mar 28 20:24 GstApp-1.5.typelib
-rw-r--r-- 1 root staff 1876 Mar 28 20:24 GstAllocators-1.5.typelib
-rw-r--r-- 1 root staff 17736 Mar 28 22:37 Nice-0.1.typelib
Then I compiled gst-python-1.7.1 and then I see the following at appropriate location:
pi#raspberrypi:~/kurento $ ls -l /usr/local/lib/python2.7/site-packages/gi/overrides/
total 640
-rw-r--r-- 1 root staff 15002 Mar 28 18:11 Gdk.py
-rw-r--r-- 1 root staff 14996 Mar 28 18:11 Gdk.pyc
-rw-r--r-- 1 root staff 14996 Mar 28 18:11 Gdk.pyo
-rwxr-xr-x 1 root staff 1141 Mar 29 22:19 _gi_gst.la
-rwxr-xr-x 1 root staff 56124 Mar 29 22:19 _gi_gst.so
-rw-r--r-- 1 root staff 2240 Mar 28 18:11 GIMarshallingTests.py
-rw-r--r-- 1 root staff 2428 Mar 28 18:11 GIMarshallingTests.pyc
-rw-r--r-- 1 root staff 2428 Mar 28 18:11 GIMarshallingTests.pyo
-rw-r--r-- 1 root staff 8147 Mar 28 18:11 Gio.py
-rw-r--r-- 1 root staff 8176 Mar 28 18:11 Gio.pyc
-rw-r--r-- 1 root staff 8075 Mar 28 18:11 Gio.pyo
-rw-r--r-- 1 root staff 33233 Mar 28 18:11 GLib.py
-rw-r--r-- 1 root staff 31701 Mar 28 18:11 GLib.pyc
-rw-r--r-- 1 root staff 31656 Mar 28 18:11 GLib.pyo
-rw-r--r-- 1 root staff 26255 Mar 28 18:11 GObject.py
-rw-r--r-- 1 root staff 23401 Mar 28 18:11 GObject.pyc
-rw-r--r-- 1 root staff 23401 Mar 28 18:11 GObject.pyo
-rw-r--r-- 1 root staff 2785 Mar 29 22:19 GstPbutils.py
-rw-r--r-- 1 root staff 2584 Mar 29 22:19 GstPbutils.pyc
-rw-r--r-- 1 root staff 2584 Mar 29 22:19 GstPbutils.pyo
-rw-r--r-- 1 root staff 11570 Mar 29 22:19 Gst.py
-rw-r--r-- 1 root staff 16602 Mar 29 22:19 Gst.pyc
-rw-r--r-- 1 root staff 16602 Mar 29 22:19 Gst.pyo
-rw-r--r-- 1 root staff 56202 Mar 28 18:11 Gtk.py
-rw-r--r-- 1 root staff 64602 Mar 28 18:11 Gtk.pyc
-rw-r--r-- 1 root staff 64602 Mar 28 18:11 Gtk.pyo
-rw-r--r-- 1 root staff 12820 Mar 28 18:11 __init__.py
-rw-r--r-- 1 root staff 13128 Mar 28 18:11 __init__.pyc
-rw-r--r-- 1 root staff 13070 Mar 28 18:11 __init__.pyo
-rw-r--r-- 1 root staff 1705 Mar 28 18:11 keysyms.py
-rw-r--r-- 1 root staff 1137 Mar 28 18:11 keysyms.pyc
-rw-r--r-- 1 root staff 1137 Mar 28 18:11 keysyms.pyo
-rw-r--r-- 1 root staff 1679 Mar 28 18:11 Pango.py
-rw-r--r-- 1 root staff 1727 Mar 28 18:11 Pango.pyc
-rw-r--r-- 1 root staff 1727 Mar 28 18:11 Pango.pyo
With this setup, I expect to see Gst module being loaded from gi repository.
>>> sys.path
['/usr/local/lib/python2.7/site-packages', '', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-arm-linux-gnueabihf', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
>>> import gi
>>> from gi.repository import Gst
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name Gst
>>> gi.require_version('Gst','1.5')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 102, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available
>>>
But this is not happening. Please, your help is needed to import the Gst modules into python. Has anyone come across similar situation?
Thanks!
GObject instrospection need type descriptions located at /usr/lib/girepository-1.0
In my case I have:
/usr/lib/girepository-1.0$ ls Gst*1.5*
Gst-1.5.typelib GstFft-1.5.typelib GstRtp-1.5.typelib
GstAllocators-1.5.typelib GstGL-1.5.typelib GstRtsp-1.5.typelib
GstApp-1.5.typelib GstInsertBin-1.5.typelib GstSdp-1.5.typelib
GstAudio-1.5.typelib GstMpegts-1.5.typelib GstTag-1.5.typelib
GstBase-1.5.typelib GstNet-1.5.typelib GstVideo-1.5.typelib
GstCheck-1.5.typelib GstPbutils-1.5.typelib
GstController-1.5.typelib GstPlayer-1.5.typelib
Try installing typelib files there.
I don't have any Gst*.py files installed, with the types description is enough.
Edit
Defining GI_TYPELIB_PATH pointing it to the directory containing the typelib files, in your case /usr/local/lib/girepository-1.5, also solves the problem.
Okie, I have the following files:
total 32
drwxr-xr-x 12 al staff 408B Feb 28 11:36 ./
drwxr-xr-x+ 40 al staff 1.3K Feb 28 10:07 ../
drwxr-xr-x 3 al staff 102B Oct 19 20:38 Install OS X Yosemite.app/
-rw-r--r-- 1 al staff 7B Dec 15 13:35 file1
-rw-r--r-- 1 al staff 4B Dec 15 13:35 file2
-rw-r--r-- 1 al staff 11B Dec 15 13:35 file3.part
-rw-r--r-- 1 al staff 0B Feb 28 11:36 file4.art
-rwxr-xr-x 1 al staff 1.9K Feb 28 11:35 show.pl*
drwxr-xr-x 2 al staff 68B Feb 28 10:07 test1/
drwxr-xr-x 6 al staff 204B Feb 28 10:12 test2/
drwxr-xr-x 3 al staff 102B Feb 28 10:07 test3/
drwxr-xr-x 3 al staff 102B Feb 28 10:12 test4/
Now I need a regexp that will do the following:
3 or more characters (to omit . and ..) of any type NOT ending in the string .part (but ending in anything else is OK).
The following almost works, but it will not match .app and .art (which it should).
print $file =~ m/^.{3,}[^(\.part)]$/i;
And please believe me when I say... I have TRIED (for a loooong time)
You need to use a negative lookahead assertion at the start.
print $file =~ m/^(?!.*\.part$).{3,}/i;
DEMO
Asserts that the string going to be matched won't contain .part string at the last. If yes, then match the string which has three or more characters. $ asserts that we are at the end.
I can't seem to get Fabric running correctly. I found this article which doesn't solve the issue for me Getting Fabric Python Library to Work
I installed Python using Homebrew brew install python (this also installs PIP):
Running which python I get:
/usr/local/Cellar/python/2.7.3/bin/python
I then installed fabric pip install fabric
Requirement already satisfied (use --upgrade to upgrade): fabric in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): ssh>=1.7.14 in /usr/local/lib/python2.7/site-packages (from fabric)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.1,!=2.4 in /usr/local/lib/python2.7/site-packages (from ssh>=1.7.14->fabric)
The other article suggests that fabric will be located at /usr/local/Cellar/python/2.7.1/bin/fab
Doing an ls on the above (but 2.7.3 in my case) gets the following (no fabric).
lrwxr-xr-x 1 darron staff 80 Oct 26 17:37 2to3 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/2to3
lrwxr-xr-x 1 darron staff 82 Oct 26 17:37 2to3-2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/2to3-2
lrwxr-xr-x 1 darron staff 84 Oct 26 17:37 2to3-2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/2to3-2.7
-r-xr-xr-x 1 darron staff 422 Oct 26 17:37 easy_install
-r-xr-xr-x 1 darron staff 430 Oct 26 17:37 easy_install-2.7
lrwxr-xr-x 1 darron staff 80 Oct 26 17:37 idle -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/idle
lrwxr-xr-x 1 darron staff 81 Oct 26 17:37 idle2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/idle2
lrwxr-xr-x 1 darron staff 83 Oct 26 17:37 idle2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/idle2.7
-r-xr-xr-x 1 darron staff 380 Oct 26 17:37 pip
-r-xr-xr-x 1 darron staff 388 Oct 26 17:37 pip-2.7
lrwxr-xr-x 1 darron staff 81 Oct 26 17:37 pydoc -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pydoc
lrwxr-xr-x 1 darron staff 82 Oct 26 17:37 pydoc2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pydoc2
lrwxr-xr-x 1 darron staff 84 Oct 26 17:37 pydoc2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7
lrwxr-xr-x 1 darron staff 82 Oct 26 17:37 python -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x 1 darron staff 89 Oct 26 17:37 python-config -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python-config
lrwxr-xr-x 1 darron staff 83 Oct 26 17:37 python2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2
lrwxr-xr-x 1 darron staff 90 Oct 26 17:37 python2-config -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2-config
lrwxr-xr-x 1 darron staff 85 Oct 26 17:37 python2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 darron staff 92 Oct 26 17:37 python2.7-config -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x 1 darron staff 83 Oct 26 17:37 pythonw -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pythonw
lrwxr-xr-x 1 darron staff 84 Oct 26 17:37 pythonw2 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pythonw2
lrwxr-xr-x 1 darron staff 86 Oct 26 17:37 pythonw2.7 -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x 1 darron staff 84 Oct 26 17:37 smtpd.py -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/smtpd.py
lrwxr-xr-x 1 darron staff 87 Oct 26 17:37 smtpd2.7.py -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.7.py
lrwxr-xr-x 1 darron staff 85 Oct 26 17:37 smtpd2.py -> /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/bin/smtpd2.py
I've located the actual install at /usr/local/lib/python2.7/site-packages
drwxr-xr-x 14 darron staff 476 Oct 26 17:41 Crypto
drwxr-xr-x 9 darron staff 306 Oct 26 17:41 Fabric-1.4.3-py2.7.egg-info
drwxr-xr-x 10 darron staff 340 Oct 26 17:37 distribute-0.6.28-py2.7.egg
-rw-r--r-- 1 darron staff 237 Oct 26 17:37 easy-install.pth
drwxr-xr-x 10 darron staff 340 Oct 26 17:41 fabfile
drwxr-xr-x 41 darron staff 1394 Oct 26 17:41 fabric
drwxr-xr-x 7 darron staff 238 Oct 22 08:13 git_remote_helpers
lrwxr-xr-x 1 darron staff 93 Oct 22 08:13 git_remote_helpers-0.1.0-py2.7.egg-info -> ../../../Cellar/git/1.8.0/lib/python2.7/site-packages/git_remote_helpers-0.1.0-py2.7.egg-info
drwxr-xr-x 4 darron staff 136 Oct 26 17:37 pip-1.2.1-py2.7.egg
drwxr-xr-x 7 darron staff 238 Oct 26 17:41 pycrypto-2.6-py2.7.egg-info
-rw-r--r-- 1 darron staff 144 Oct 26 17:37 setuptools-0.6c11-py2.7.egg-info
-rw-r--r-- 1 darron staff 34 Oct 26 17:37 setuptools.pth
-rw-r--r-- 1 darron staff 1224 Oct 26 17:37 sitecustomize.py
-rw-r--r-- 1 darron staff 600 Oct 26 17:37 sitecustomize.pyc
drwxr-xr-x 72 darron staff 2448 Oct 26 17:41 ssh
drwxr-xr-x 8 darron staff 272 Oct 26 17:41 ssh-1.7.14-py2.7.egg-info
My question is how do I get it working? Running fab at the prompt gets me:
-bash: fab: command not found
Note - my paths are set in /etc/paths like so:
/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin
The link you posted is outdated. fab should be located in the /usr/local/share/python directory -- that's where Homebrew's Python puts scripts from installed modules. Add /usr/local/share/python to your PATH.