Export ArangoDB values to bash script
up vote
0
down vote
favorite
I have a bash script that needs the count of records/documents that exist for a given arango collection. This seemed easy enough, I used the following arangosh
call:
records=$(docker exec -it arango arangosh --javascript.execute scripts/getCount.js $collection --server.password '')
which then runs the following script:
#!/usr/bin/arangosh --javascript.execute
var collection = ARGUMENTS[0];
var doc = db[collection];
var c = doc.count();
print(c);
This appears to work, but when I echo $records
I get the correct value but it appears bolded. This leads to other reading issues so I redirected the docker exec
call to cat -v
and got the following output:
^[[1m#####^[[0m^M
The #### is my record value and it is correct. How do I either properly print the value out of arangosh
or out of docker exec
? Or is the only path to strip these hidden ansi characters from my value?
UPDATE:
I was able to attempt docker exec -it arango arangosh
and attempt the command db._collection('my_collection').count()
directly. This returned a bolded value which I believe means that it contains the hidden characters (arangosh
doesn't have cat
defined so I couldn't verify 100%).
With that said I believe the question is, can this be exported in plain text or do I need to sed
substitute these characters after my script receives the response?
bash shell-script docker
New contributor
add a comment |
up vote
0
down vote
favorite
I have a bash script that needs the count of records/documents that exist for a given arango collection. This seemed easy enough, I used the following arangosh
call:
records=$(docker exec -it arango arangosh --javascript.execute scripts/getCount.js $collection --server.password '')
which then runs the following script:
#!/usr/bin/arangosh --javascript.execute
var collection = ARGUMENTS[0];
var doc = db[collection];
var c = doc.count();
print(c);
This appears to work, but when I echo $records
I get the correct value but it appears bolded. This leads to other reading issues so I redirected the docker exec
call to cat -v
and got the following output:
^[[1m#####^[[0m^M
The #### is my record value and it is correct. How do I either properly print the value out of arangosh
or out of docker exec
? Or is the only path to strip these hidden ansi characters from my value?
UPDATE:
I was able to attempt docker exec -it arango arangosh
and attempt the command db._collection('my_collection').count()
directly. This returned a bolded value which I believe means that it contains the hidden characters (arangosh
doesn't have cat
defined so I couldn't verify 100%).
With that said I believe the question is, can this be exported in plain text or do I need to sed
substitute these characters after my script receives the response?
bash shell-script docker
New contributor
1
I'm curious what happens if you omit the -t option
– Jeff Schaller
2 days ago
It looks like that works!
– Xtremefaith
2 days ago
@Xtremefaith There was a similar question recently: unix.stackexchange.com/questions/487117/…
– Haxiel
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a bash script that needs the count of records/documents that exist for a given arango collection. This seemed easy enough, I used the following arangosh
call:
records=$(docker exec -it arango arangosh --javascript.execute scripts/getCount.js $collection --server.password '')
which then runs the following script:
#!/usr/bin/arangosh --javascript.execute
var collection = ARGUMENTS[0];
var doc = db[collection];
var c = doc.count();
print(c);
This appears to work, but when I echo $records
I get the correct value but it appears bolded. This leads to other reading issues so I redirected the docker exec
call to cat -v
and got the following output:
^[[1m#####^[[0m^M
The #### is my record value and it is correct. How do I either properly print the value out of arangosh
or out of docker exec
? Or is the only path to strip these hidden ansi characters from my value?
UPDATE:
I was able to attempt docker exec -it arango arangosh
and attempt the command db._collection('my_collection').count()
directly. This returned a bolded value which I believe means that it contains the hidden characters (arangosh
doesn't have cat
defined so I couldn't verify 100%).
With that said I believe the question is, can this be exported in plain text or do I need to sed
substitute these characters after my script receives the response?
bash shell-script docker
New contributor
I have a bash script that needs the count of records/documents that exist for a given arango collection. This seemed easy enough, I used the following arangosh
call:
records=$(docker exec -it arango arangosh --javascript.execute scripts/getCount.js $collection --server.password '')
which then runs the following script:
#!/usr/bin/arangosh --javascript.execute
var collection = ARGUMENTS[0];
var doc = db[collection];
var c = doc.count();
print(c);
This appears to work, but when I echo $records
I get the correct value but it appears bolded. This leads to other reading issues so I redirected the docker exec
call to cat -v
and got the following output:
^[[1m#####^[[0m^M
The #### is my record value and it is correct. How do I either properly print the value out of arangosh
or out of docker exec
? Or is the only path to strip these hidden ansi characters from my value?
UPDATE:
I was able to attempt docker exec -it arango arangosh
and attempt the command db._collection('my_collection').count()
directly. This returned a bolded value which I believe means that it contains the hidden characters (arangosh
doesn't have cat
defined so I couldn't verify 100%).
With that said I believe the question is, can this be exported in plain text or do I need to sed
substitute these characters after my script receives the response?
bash shell-script docker
bash shell-script docker
New contributor
New contributor
edited 2 days ago
New contributor
asked 2 days ago
Xtremefaith
1032
1032
New contributor
New contributor
1
I'm curious what happens if you omit the -t option
– Jeff Schaller
2 days ago
It looks like that works!
– Xtremefaith
2 days ago
@Xtremefaith There was a similar question recently: unix.stackexchange.com/questions/487117/…
– Haxiel
yesterday
add a comment |
1
I'm curious what happens if you omit the -t option
– Jeff Schaller
2 days ago
It looks like that works!
– Xtremefaith
2 days ago
@Xtremefaith There was a similar question recently: unix.stackexchange.com/questions/487117/…
– Haxiel
yesterday
1
1
I'm curious what happens if you omit the -t option
– Jeff Schaller
2 days ago
I'm curious what happens if you omit the -t option
– Jeff Schaller
2 days ago
It looks like that works!
– Xtremefaith
2 days ago
It looks like that works!
– Xtremefaith
2 days ago
@Xtremefaith There was a similar question recently: unix.stackexchange.com/questions/487117/…
– Haxiel
yesterday
@Xtremefaith There was a similar question recently: unix.stackexchange.com/questions/487117/…
– Haxiel
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Still hoping for a better answer but I was able to get what I needed with the following:
imported=`docker exec -it arango arangosh --javascript.execute scripts/getRecords.js $collection --server.password '' | cat -v | sed 's/(^[[1m)//g;s/(^[[0m^M)//g'`
This simply passed the verbose output from docker to a sed
substitution. Considering that for this script I expect the characters to be the same for all collections I am supplying to this script this should do the trick (just very limited).
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Xtremefaith is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487453%2fexport-arangodb-values-to-bash-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Still hoping for a better answer but I was able to get what I needed with the following:
imported=`docker exec -it arango arangosh --javascript.execute scripts/getRecords.js $collection --server.password '' | cat -v | sed 's/(^[[1m)//g;s/(^[[0m^M)//g'`
This simply passed the verbose output from docker to a sed
substitution. Considering that for this script I expect the characters to be the same for all collections I am supplying to this script this should do the trick (just very limited).
New contributor
add a comment |
up vote
0
down vote
Still hoping for a better answer but I was able to get what I needed with the following:
imported=`docker exec -it arango arangosh --javascript.execute scripts/getRecords.js $collection --server.password '' | cat -v | sed 's/(^[[1m)//g;s/(^[[0m^M)//g'`
This simply passed the verbose output from docker to a sed
substitution. Considering that for this script I expect the characters to be the same for all collections I am supplying to this script this should do the trick (just very limited).
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
Still hoping for a better answer but I was able to get what I needed with the following:
imported=`docker exec -it arango arangosh --javascript.execute scripts/getRecords.js $collection --server.password '' | cat -v | sed 's/(^[[1m)//g;s/(^[[0m^M)//g'`
This simply passed the verbose output from docker to a sed
substitution. Considering that for this script I expect the characters to be the same for all collections I am supplying to this script this should do the trick (just very limited).
New contributor
Still hoping for a better answer but I was able to get what I needed with the following:
imported=`docker exec -it arango arangosh --javascript.execute scripts/getRecords.js $collection --server.password '' | cat -v | sed 's/(^[[1m)//g;s/(^[[0m^M)//g'`
This simply passed the verbose output from docker to a sed
substitution. Considering that for this script I expect the characters to be the same for all collections I am supplying to this script this should do the trick (just very limited).
New contributor
New contributor
answered 2 days ago
Xtremefaith
1032
1032
New contributor
New contributor
add a comment |
add a comment |
Xtremefaith is a new contributor. Be nice, and check out our Code of Conduct.
Xtremefaith is a new contributor. Be nice, and check out our Code of Conduct.
Xtremefaith is a new contributor. Be nice, and check out our Code of Conduct.
Xtremefaith is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487453%2fexport-arangodb-values-to-bash-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I'm curious what happens if you omit the -t option
– Jeff Schaller
2 days ago
It looks like that works!
– Xtremefaith
2 days ago
@Xtremefaith There was a similar question recently: unix.stackexchange.com/questions/487117/…
– Haxiel
yesterday