3 Replies Latest reply: Jul 16, 2014 2:45 PM by d1g1talphyre RSS

    execute command in command line.

    Gonterman1201 Community Member

      I am trying to connect to a local database. I can use the terminal to execute commands to the database that work. The trick is that I am having difficulty sending those commands from bridge. This is what I have tried.

       

      app.system("Mongod --fork");
      app.system("mongo");
      app.system("use mydb");
      app.system("db.testData.update({ name: 'bg'}, { $set: { name: 'Brett Gonterman'}})");
      

       

      if I type this manually it works. If I send this through Bridge nothing happens.

      How can I execute this?

        • 1. Re: execute command in command line.
          Gonterman1201 Community Member

          I tried making an executable like this

          app.system("/Users/bagonterman/Desktop/MongoData.sh");
          

          but it does nothing. In the toolkit it says that system runs just like command line. So how is this not running?

          • 2. Re: Re: execute command in command line.
            Gonterman1201 Community Member

            I also tried this

            app.system("osascript do shell script '/Users/bagonterman/Desktop/MongoData.sh'");
            
            • 3. Re: execute command in command line.
              d1g1talphyre Community Member

              BUMP!

               

              I figured it out.  Let me walk you through so you understand.  I've been having the same issues you have been having here.

               

              So at first I tried what you were trying to no avail.  Then I tried this...

              poo = "find /Volumes/IllustratedUses -iname '" + DocumentID + "' | xargs -I '{}' cp {} /Volumes/Archive_ME/tempDir/
              

               

              and behold, it worked.  I was shocked.  So I tried running a python script.  wa wa waaaa, nothing.

              I went and talked to a buddy in our photo studio who is really good with bash on mac.  He said check your enviroment. 

              The trick is to manually set your path variables in the line of code you want to run.

              poop = "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin; cd /Volumes/Archive_Me/tempDir/; sh illuse.sh"
              app.system(poop)
              

               

              and my friend that worked.  I hope this helps other people in the future.