Export ArangoDB values to bash script











up vote
0
down vote

favorite
1












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?










share|improve this question









New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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















up vote
0
down vote

favorite
1












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?










share|improve this question









New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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?










share|improve this question









New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago





















New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Xtremefaith

1032




1032




New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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




    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










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).






share|improve this answer








New contributor




Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















    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.










    draft saved

    draft discarded


















    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).






    share|improve this answer








    New contributor




    Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      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).






      share|improve this answer








      New contributor




      Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        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).






        share|improve this answer








        New contributor




        Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        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).







        share|improve this answer








        New contributor




        Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 2 days ago









        Xtremefaith

        1032




        1032




        New contributor




        Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Xtremefaith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















            Xtremefaith is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            サソリ

            広島県道265号伴広島線

            Setup Asymptote in Texstudio