I had to build a RoR web application that executes linux commands, for instance on my web page I have an "ls" button, how can I make the system run the command, retrieve the output and show the output on my web page? Is there a particular gem?
I think that you should be able to do that simply by doing something like:
<pre>
<?= `ls` ?>
</pre>
I don't think you have access to the machine from the web app due to security policies. Anyway with Ruby you can use this gem.
Hope this helps.
Check out this extremely informative link: http://tech.natemurray.com/2007/03/ruby-shell-commands.html. He describes the advantages / disadvantages to the various ways ruby can call shell commands, including how to pass stdin, capture stderr, etc.
Related
I would like to enable caching in ArangoDB, automatically when my app start.
I'm using docker-compose to start the whole thing but apparently there's no simple parameter to enable caching in ArangoDB official image.
According to the doc, all the files in /docker-entrypoint-initdb.d/ are executed at container start. So I added a js file with that code:
require('#arangodb/aql/cache').properties({mode: 'on'});
It is indeed executed but caching doesn't seem to be enabled (from what I see with arangosh within the container).
My app is a JS app using arangojs, so if I can do it this way, I'd be happy too.
Thanks!
According to the performance and server config docs, you can enable caching in several ways.
Your method of adding require("#arangodb/aql/cache").properties({ mode: "on" }); to a .js file in the /docker-entrypoint-initdb.d/ directory should work, but keep an eye on the logs. You may need to redirect log output with a different driver (journals, syslog, etc.) to see what's going on. Make sure to run the command via arangosh to see if it works.
If that's a bust, you might want to see if there is a way to pass parameters at runtime (such as --query.cache-mode on). Unfortunately, I don't use Docker Compose, so I can't give you direct advice here, but try something like -e QUERY.CACHE-MODE=ON
If there isn't a way to pass params, then you could modify the config file: /etc/arangodb3/arangod.conf.
And don't forget about the REST API methods for system management. You can access AQL configuration (view and alter) in the Web UI by clicking on the Support -> Rest API -> AQL.
One thing to keep in mind - I'm not sure if the caching settings are global or tied to a specific database. View the configuration on multiple databases (including _system) to test the settings.
I have a rails app and I would like to display the log in the app itself. This will allow administrators to see what changes were recently made without entering the console and using the file with the logs. All logs will be displayed in the application administration. How is it possible to implement and what kind of gems do I need to use?
You don't need a Gem.
Add a controller, read the logfiles and render the output in HTML.
Probably need to limit the number of lines you read. Also there might be different log files to chose from.
I don't think this is a good idea though. Log files are for finding errors and you should not need them in your day to day work, unless you manage ther server.
Also they might contain sensitive data (CC Numbers, Pwds, ...) and it might get complicated when you use multiple servers with local disks.
Probably better to look at dedicated tools for this and handle logs outside of your application.
Assuming that you have git associated with your application or git bash installed in your system.
For displaying log information for the development mode, migrate to your application folder in your console/terminal and type tail -f log/development.log
I host a server and I was wondering: is there any way to run chat commands through ComputerCraft? I want to be able to run /tps through the ComputerCraft terminal and then have it print out the TPS. Help would be greatly appreciated.
Thanks.
In the new Computercraft 1.7 there is a new type of computer, the Command Computer. It allows the user to run commands the same way as shell.run("mkdir", "foo"). It can only be obtained by ops, and can only directly be controlled (we are talking without using rednet and such) by ops
commands.exec(string command) -- Runs and outputs command output in chat.
commands.execAsync(string command) -- Quietly runs command without output.
Here is the wiki page:
Commands (API)
But if we are talking 1.6.4 (Which almost all modpacks use) there is no "stock" version of doing that.
Hope it helps /Tyrerexus
I believe that you can use this thing called the Chat Box.
http://ftbwiki.org/Chat_Box
It's not part of the default Computercraft, however. It is part of the Misc Peripherals mod I believe.
I use Dreamweaver heavily for modifying Liferay templates (Velocity files), and then have to run Apache Ant from Command Prompt to deploy the WAR to Tomcat . Is there anyway I can streamline this process so I can save/deploy straight from Dreamweaver?
I tried to setup a site and specify Tomcat as the local server, but obviously Dreamweaver just tries to push the raw file and does deploy the WAR.. Is there some sort of extension or way I can call Apache Ant from Dreamweaver?
Thanks!
I've not seen such an extension, you can search for one at the Adobe Exchange: http://www.adobe.com/go/exchange , however if there isn't one already available, which I suspect there isn't, it would be possible to write one of your own. The following links are for the extending Dreamweaver, and Dreamweaver extensibility APIs:
http://help.adobe.com/en_US/dreamweaver/cs/extend/index.html
http://help.adobe.com/en_US/dreamweaver/cs/apiref/index.html
In this particular case, I believe that you'd need to use an undocumented API call to communicate with an external process (in your case Ant), such as DWfile.runCommandLine() or MM.runCommandLine(). Paul Boon found these and blogged about them and a couple of others here:
http://communitymx.com/blog/index.cfm?newsid=179&blogger=35
We have an internal and external facing asp.net mvc app running under mono on ubuntu 10.04 LTS. There is also a complicated (native, not mono) command line app that users use on the same server. They log on via ssh to do this. We have the security for the ssh users pretty locked down, so they can't do very much other than run the command line app.
The users of these apps have to:
login via ssh to the server, run the command line app with whatever command line switches are required which then does some long running processing and puts a report in the db of the web app.
Login to the web app, then set some options for publishing a report via the web app.
The users of the apps want to skip step 1 and do it all in the web app. I am thinking of creating a service that regulary polls the db for command line app jobs to run. The jobs would be created by the users as desired in the web app.
The problem is, the users want a box in the web app where they can just fill in any command line options. But I don't want them to do something like this:
-a dothis -b dothis & rm importantfile.txt
...in case the user's credentials to the web app are somehow compromised. I want to make sure that only that command line app can be used and nothing else. I am thinking of preventing the characters ! | < > & / \ $ ( ) from being allowed, which looks like are not required by the command line app.
Is that good enough? Are there any other shell tricks I should know about? Should I take a different approach?
I really don't want to have to write some sort of parser for the arguments that the users supply, because there are a ton of them that the users like to use.
Instead of running the command line as a shell command (launching the shell to launch the program), can you launch the program itself as a new process? I believe that's what the answer here is doing: Execute a command line utility in ASP.NET . If the actual program is launched as a process, rather than a shell, then things like & or rm will just be arguments to the command line utility, which should be fine if the command line utility checks for bad inputs.
If that's not feasible (although it's probably the better option), replacing all single quotes with single quote escape sequences, then placing single quotes around each of the arguments (split the string with a space as the delimeter), could provide a similar effect. Instead of making sure you avoid all possible bad characters (; can be used similarly to & in many shells), you only need to make sure that the provided arguments can't escape out of the single quotes. (You might also want to check for single quote surrounded arguments beforehand, to avoid double quoting them, and don't cound escaped spaces when splitting up arguments, etc., so that the users can provide arguments that need spaces).