This seems so simple, yet I cannot find a single source that provides a working solution.
I have a project like this:
src
-main
-resources
-bpmns
-nnn.bpmn
and I want gradle to rename all files that end with bpmn to bpmn20.xml, leaving all files that already have bpmn20.xml extensions untouched.
This is my approach:
task renameBPMN(type: Copy) {
outputs.upToDateWhen { false } //to pevent gradle from not executing this task
from('src/main/resources/bpmn/')
into('src/main/resources/bpmn/')
rename ('/^.*\\.(bpmn)$/', '$1.bpmn20.xml')
}
According to some regex testers online, the regex should match nnn.bpmn, gradle however does nothing at all.
Any ideas anyone?
This is what he needs or actually this script would do it.
Here it'll change a file: filenamebpmn or filename.bpmn to filenamebpmn20.xml or filename.bpmn20.xml respectively. It'll ignore all other files whether it's a filenamebpmn.xml or filename.bpmn.xml or any other file.
$ cat build.gradle
task renameBPMN() << {
fileTree("bpmnfolder").matching { include "*bpmn" }.each { fileName ->
println "Will be changed to new name --- " + fileName
file("${fileName}").renameTo("${fileName}20.xml")
}
}
$ ls -l bpmnfolder
total 3
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:14 1bpmn
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 14:50 2bpmn
-rw-r--r-- 1 c400093 Domain Users 6 Aug 6 14:50 3bpmn.xml
$ /cygdrive/c/gradle-2.0/bin/gradle renameBPMN
:renameBPMN
Will be changed to new name --- C:\cygwin\home\c400093\giga\goga\giga\bpmnfolder\1bpmn
Will be changed to new name --- C:\cygwin\home\c400093\giga\goga\giga\bpmnfolder\2bpmn
BUILD SUCCESSFUL
Total time: 3.153 secs
$ ls -l bpmnfolder
total 3
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:14 1bpmn20.xml
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 14:50 2bpmn20.xml
-rw-r--r-- 1 c400093 Domain Users 6 Aug 6 14:50 3bpmn.xml
$
AND
If you want to include filenames which end with bpmn as extension i.e. filename.bpmn or filenamebpmn, then use the following code.
$ ls -l bpmnfolder
total 5
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:39 1bpmn
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:39 2bpmn
-rw-r--r-- 1 c400093 Domain Users 6 Aug 6 15:39 3bpmn.xml
-rw-r--r-- 1 c400093 Domain Users 8 Aug 6 15:39 4.bpmn
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:39 5.bpmn.xml
$ cat build.gradle
task renameBPMN() << {
fileTree("bpmnfolder").matching { include "*bpmn" include "*.bpmn" }.each { fileName ->
println "Will be changed to new name --- " + fileName
file("${fileName}").renameTo("${fileName}20.xml")
}
}
$ /cygdrive/c/gradle-2.0/bin/gradle renameBPMN
:renameBPMN
Will be changed to new name --- C:\cygwin\home\c400093\giga\goga\giga\bpmnfolder\1bpmn
Will be changed to new name --- C:\cygwin\home\c400093\giga\goga\giga\bpmnfolder\2bpmn
Will be changed to new name --- C:\cygwin\home\c400093\giga\goga\giga\bpmnfolder\4.bpmn
BUILD SUCCESSFUL
Total time: 4.271 secs
$ ls -l bpmnfolder
total 5
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:39 1bpmn20.xml
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:39 2bpmn20.xml
-rw-r--r-- 1 c400093 Domain Users 6 Aug 6 15:39 3bpmn.xml
-rw-r--r-- 1 c400093 Domain Users 8 Aug 6 15:39 4.bpmn20.xml
-rw-r--r-- 1 c400093 Domain Users 3 Aug 6 15:39 5.bpmn.xml
$
Modify your task to:
task rename(type: Copy) {
outputs.upToDateWhen { false } //to pevent gradle from not executing this task
from('src/main/resources/bpmn/')
into('src/main/resources/bpmn/')
exclude { resource -> !resource.file.name.endsWith('.bpmn')}
rename '(.*).bpmn', '$1.bpmn20.xml'
}
According to the gradle documentation, AbstractCopyTask::rename()'s regular expression does not need delimiters:
rename '(.*)_OEM_BLUE_(.*)', '$1$2'
Try replacing:
rename ('/^.*\\.(bpmn)$/', '$1.bpmn20.xml')
With:
rename ('^.*\\.(bpmn)$', '$1.bpmn20.xml')
Related
My repo:
/
dbt-action/
action.yml
Dockerfile
entrypoint.sh
dbt/
profiles.yml
My workflow step:
- name: Run DBT
uses: ./dbt-action
My Dockerfile:
FROM ghcr.io/dbt-labs/dbt-redshift:1.3.latest
COPY dbt .dbt
COPY entrypoint.sh /entrypoint.sh
My entrypoint:
!/bin/bash
pwd
ls -la
Outputs the following:
drwxr-xr-x 6 1001 123 4096 Jan 7 13:06 .
drwxr-xr-x 6 root root 4096 Jan 7 13:06 ..
drwxr-xr-x 8 1001 123 4096 Jan 7 13:06 .git
drwxr-xr-x 3 1001 123 4096 Jan 7 13:06 .github
drwxr-xr-x 3 1001 123 4096 Jan 7 13:06 blah
-rw-r--r-- 1 1001 123 1744 Jan 7 13:06 README.md
drwxr-xr-x 3 1001 123 4096 Jan 7 13:06 dbt-action
Expected output:
Same as above but with additional directory .dbt coming from COPY dbt .dbt in my Dockerfile.
Why don't I see dir .dbt when I ls -la in my entrypoint?
Seems like you are executing your ‘Docker build’ from the wrong working directory, since the ‘dbt-action’ folder is present, but not it contents. Can you double check the PWD before you build?
As mentioned at Terraform Resource: Connection Error while executing apply
I changed my code to the the below
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("/id_rsa.pem")
}
inline = [
"chmod +x /tmp/start_node.sh",
"sudo sed -i -e 's/\r$//' /tmp/start_node.sh", # Remove the spurious CR characters.
"sudo /tmp/start_node.sh",
]
}
But I still get the same error
Error: Invalid function argument
on explorer.tf line 60, in resource "aws_instance" "explorer":
60: private_key = file("/id_rsa.pem")
Invalid value for "path" parameter: no file exists at /id_rsa.pem;
this function works only with files that are distributed as part of the
configuration source code, so if this file will be created by a resource in
this configuration you must instead obtain this result from an attribute of
that resource.
ls -la ooutput
total 156
drwxr-xr-x 10 CORP\mayuresh CORP\domain users 4096 Jan 12 14:29 .
drwxr-xr-x 16 CORP\mayuresh CORP\domain users 4096 Jan 10 13:10 ..
drwxr-xr-x 12 CORP\mayuresh CORP\domain users 4096 Jan 12 09:49 byoc-terraform
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 11 11:57 controllers
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 188 Jan 10 13:27 .env
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1582 Jan 10 17:12 fetchUserData.js
drwxr-xr-x 9 CORP\mayuresh CORP\domain users 4096 Jan 12 13:14 .git
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 629 Jan 10 13:27 .gitignore
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 107 Dec 30 06:49 .gitmodules
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1765 Jan 12 13:21 id_rsa.pem
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1488 Jan 10 13:27 index.js
drwxr-xr-x 3 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 models
drwxr-xr-x 221 CORP\mayuresh CORP\domain users 12288 Jan 10 13:30 node_modules
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1058 Jan 10 13:27 package.json
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 78791 Jan 10 13:27 package-lock.json
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 routes
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 17:01 utils
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 VMCreationFiles```
Have you tried using the full path? Especially beneficial if you are using modules.
I.E:
private_key = file("${path.module}/id_rsa.pem")
Or I think even this will work
private_key = file("./id_rsa.pem")
I believe your existing code is looking for the file at the root of your filesystem.
Your path to the .pem is wrong. It looks like the file exists in your $HOME directory.
You can provide the absolute path of the id_rsa.pem file if that file is outside of path.module, path.root, path.cwd
To provide the absolute path
Fetch the full path of the file How to get full path of a file?
Paste the path in:
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("<Absolute path to .pem file e.g /home/ubuntu/id_rsa.pem>")
}
I wanted to move our database from mysql (community version) to mariadb with the further use of php7.1/apache2.4.25... So I have to compile mariadb in our new production environment. I compiled it with these options:
cmake -DCMAKE_CXX_FLAGS:STRING="-std=c++11" -DCONC_WITH_CURL=ON -DCONC_WITH_EXTERNAL_ZLIB=ON -DDISABLE_SHARED=OFF -DCONC_WITH_MYSQLCOMPAT:BOOL=ON -DPLUGIN_CLIENT_ED25519:STRING=DYNAMIC .
make all && make install
The mysql community version has a libmysqlclient.so in /usr/local/mysql/lib located. If I compile it with the options given above I only found these files in /usr/local/mysql/lib (MariaDB 10.2.6):
# ls -l /usr/local/mysql/lib/
total 3572
-rw-r--r-- 1 root root 2305518 Jul 4 08:14 libmariadbclient.a
lrwxrwxrwx 1 root root 15 Jul 4 08:31 libmariadb.so -> libmariadb.so.3
-rwxr-xr-x 1 root root 1297664 Jul 4 08:14 libmariadb.so.3
-rw-r--r-- 1 root root 48406 Jul 4 08:14 libmysqlservices.a
drwxr-xr-x 2 root root 4096 Jul 4 08:31 plugin
How can I get libmysqlclient.so? There isn't also any libmariadbclient.so just libmariadbclient.a ...
Thank you for further hints!
OK, now I found a solution.
I've just did a symbolic link to libmariadb.so and it now looks like the following:
ls -l /usr/local/mysql/lib/
total 3572
-rw-r--r-- 1 root root 2305518 Jul 4 16:21 libmariadbclient.a
lrwxrwxrwx 1 root root 15 Jul 4 16:39 libmariadb.so -> libmariadb.so.3
-rwxr-xr-x 1 root root 1297664 Jul 4 16:21 libmariadb.so.3
lrwxrwxrwx 1 root root 15 Jul 4 16:40 libmysqlclient_r.so -> libmariadb.so.3
lrwxrwxrwx 1 root root 15 Jul 4 16:40 libmysqlclient.so -> libmariadb.so.3
-rw-r--r-- 1 root root 48406 Jul 4 16:21 libmysqlservices.a
drwxr-xr-x 2 root root 4096 Jul 4 16:39 plugin
In this case PHP 7 would finally find the mysql libraries...
Here are some sample input I obtain from doing ls -l :
-rwxr-xr-x 1 root root 1779 Jan 10 2014 zcmp
-rwxr-xr-x 1 root root 5766 Jan 10 2014 zdiff
-rwxr-xr-x 1 root root 142 Jan 10 2014 zegrep
-rwxr-xr-x 1 root root 142 Jan 10 2014 zfgrep
-rwxr-xr-x 1 root root 2133 Jan 10 2014 zforce
-rwxr-xr-x 1 root root 5940 Jan 10 2014 zgrep
lrwxrwxrwx 1 root root 8 Dec 5 2015 ypdomainname -> hostname
I would like to print out the last column and 5th column using ONLY sed like this:
zcmp 1779
zdiff 5766
zegrep 142
zfgrep 142
zforce 2133
zgrep 5940
ypdomainname -> hostname 8
I'm trying to find a regex to match but have not succeeded. And I'm not allowed to use awk or cut either.
Thank you in advance.
Try this;
ls -l | sed -r 's/^(\S+\s+){5}(\S+\s+){3}/\1/' | sed 's/^\(.*\) \(.*\)$/\2\ \1/g'
I am doing a django project with Sublime Text 2 on OSX-Lion. I have installed virtualenv, so my project is in "/Users/myname/Virtualenvs/"
I need to use a 'sudo' for each command (syncdb, runserver), can I change these rules whithout moving my project and is it normal ?
These are parameters after a "sudo python manage.py startproject"
Chmod infos :
drwxr-xr-x 17 root staff 578 10 jul 23:24 Platform
-rw-r--r-- 1 root staff 155648 10 jul 23:24 database.sqlite3
-rw-r--r-- 1 root staff 251 10 jul 23:09 manage.py
and in Platform :
drwxrwxr-x# 9 Nicolas staff 306 10 jul 23:13 Templates
-rw-r--r--# 1 Nicolas staff 0 4 jul 16:53 __init__.py
-rw-r--r--# 1 Nicolas staff 144 4 jul 16:54 __init__.pyc
-rw-rw-r--# 1 Nicolas staff 123 10 jul 23:13 admin.py
-rw-r--r-- 1 root staff 321 10 jul 23:24 admin.pyc
-rw-rw-r--# 1 Nicolas staff 1706 10 jul 23:13 models.py
-rw-r--r-- 1 root staff 2603 10 jul 23:22 models.pyc
-rw-r--r--# 1 Nicolas staff 5309 10 jul 23:06 settings.py
-rw-r--r-- 1 root staff 3058 10 jul 23:22 settings.pyc
-rw-r--r--# 1 Nicolas staff 639 10 jul 23:06 urls.py
-rw-r--r-- 1 root staff 784 10 jul 23:24 urls.pyc
-rw-rw-r--# 1 Nicolas staff 1895 10 jul 23:06 views.py
-rw-r--r-- 1 root staff 2745 10 jul 23:24 views.pyc
-rw-r--r--# 1 Nicolas staff 1138 10 jul 23:05 wsgi.py
-rw-r--r-- 1 root staff 1047 10 jul 23:24 wsgi.pyc
You'll need to change ownership of all the root-owned files to yourself, but otherwise there shouldn't be any need for sudo here.