w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to use script in interactive shell
Well you either have to run this as a program using if __name__ == 'main': # Your code goes here. This will run when called from command line. or if you are in the python interpreter you have to import "my" with: >>> import my

Categories : Python

how to execute in php interactive mode
Ctrl+d will send the end-of-file character and cause the script to be executed. See also How does the interactive php shell work? Interactive Shell and Interactive Mode are not the same thing, despite the similar names and functionality. If you type php -a and get a response of 'Interactive Shell' followed by a php> prompt, you have interactive shell available (PHP was compiled with readline support). If instead you get a response of 'Interactive mode enabled', you DO NOT have interactive shell available and this article does not apply to you. So if you get only "Interactive mode enabled", then you'll only be able to type in PHP code and then when you're done, send PHP an EOF to execute it. "EOF" means the end-of-file character.

Categories : PHP

How to run a python script from IDLE interactive shell?
The IDLE shell window is not the same as a terminal shell (e.g. running sh or bash). Rather, it is just like being in the Python interactive interpreter (python -i). The easiest way to run a script in IDLE is to use the Open command from the File menu (this may vary a bit depending on which platform you are running) to load your script file into an IDLE editor window and then use the Run -> Run Module command (shortcut F5).

Categories : Python

C library to easily create interactive shell
History is usually managed by readline or libedit. Parsing is usually done with flex/bison.

Categories : C

PyDev Interactive Python Shell in Eclipse
From what I know, we can open multiple consoles of a particular type in Eclipse. Whenever we run a script within PyDev, it opens a new console to which it prints the output from the script (including error output). However this is just a new console that is added to the list of already opened consoles. Hence you can switch back to a previously open console by using the Display Selected Console option within the console view ( refer here for a list of all the available console options). What does this mean? You can open a new Python interpretor console using the Open Console option within the Eclipse Console view. You can define your methods and play with the interpretor within that console. You now run a Python script that is open within the PyDev editor. A new console gets opened up whe

Categories : Python

Instantiating a Class in Interactive Python Shell
I copy pasted your code into a file named "file.py". Then I did the following: from file import * avgbox(1, 2, 3) It worked. Maybe your mistake was that you were doing from file.py import * when you should just be doing from file import * Remember that when Python searches for module names, it automatically appends .py to the name of the module if it's looking for a Python file within the current directory. Of course, you can also search within packages using the from syntax, but that's a different story.

Categories : Python

getting error in a defined class name when importing in interactive shell
When you import a module, the names defined in it are not automatically added to the global namespace. You need to do: import something r = something.Rectangle() or from something import Rectangle r = Rectangle()

Categories : Python

python: load thrift classes and run interactive shell
I'm not really sure what you mean by "with my local thrift packages already imported", but if you want to start an interactive shell with a specific set of symbols already defined in the global namespace, I'd do it in a function, and import the symbols in there, to avoid polluting the sub-shell with any unwanted symbols from the rest of your code. For example, if you wanted to start an interactive shell with sys and os already imported, then something like this ought to work... >>> import code >>> def start_shell(): ... import sys, os ... code.interact(local=locals()) ... >>> start_shell() Python 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >&g

Categories : Python

How can I execute a shell-script in a Bash sub-shell?
You can do the same but without eval. with-env-overrides() { ( source $HOME/.env-overrides "$@" ) } Example: $ cat ~/.env-overrides export A=1000 $ export | grep ^A= $ with-env-overrides export | ^grep A= declare -x A="1000" As you can see, in the second case, you've got an environment with the A variable.

Categories : Linux

Python interactive shell running copy.py on current directory?
When Python imports a module, the module search path order is: the directory containing the input script (or the current directory). PYTHONPATH (a list of directory names, with the same syntax as the shell variable PATH). the installation-dependent default. Now, when raising an exception, Python runs specific code. Any code that tries to import the copy Python module will instead import your module and print the string in it. This is why you shouldn't use names that are also names of standard Python modules.

Categories : Python

How to immediately execute AsyncHTTPClient() without server (using interactive interpreter)
Yes, but you should start an IOLoop, example from docs: from tornado import ioloop from tornado.httpclient import AsyncHTTPClient def handle_request(response): if response.error: print "Error:", response.error else: print response.body ioloop.IOLoop.instance().stop() http_client = AsyncHTTPClient() http_client.fetch("http://www.google.com/", handle_request) ioloop.IOLoop.instance().start()

Categories : Python

Execute a script in phantomjs interactive (REPL) mode
Looks like REPL mode is borked and and an overhaul is underway: https://github.com/ariya/phantomjs/issues/11180

Categories : Javascript

Modify existing code for creating menu names in an interactive shell script
Assuming you can pull out the "Add", "Delete" ... and other "titles" from the 7th line of each *.mod file, then you need to modify your script where it looks at the file a1.out somewhere before the line which seems to create the menu, namely: tr ' ' ' ' < ~/a1.out > ~/b.dat. I say "assuming" because, even though you mention awk NR==7, I don't see where you are using it in the script. In any case, if you can get the "title" from the 7th line of a given *.mod file, then you can get the menu "name" from the file name (which seems to be the way you are constructing your menu) like this: awk '{ln=length(ARGV[1]); if(NR==7) print substr(ARGV[1],0,ln-4)"..."$0}' ABC.mod outputs: ABC...Add There's may be a shorter, easier way to do this using sed, but you mentioned awk. For me at le

Categories : Bash

error: cannot convert 'double (evaluator::*)(double, double)' to 'double (*)(double, double)' in assignment
This: double (*ope)(double, double); should be: double (evaluator::*ope)(double, double); // ^^^^^^^^^^^^ because you are using a pointer to member.

Categories : C++

Go: execute shell command
You have to pass the program and the arguments separately. See the signature of exec.Command: func Command(name string, arg ...string) *Cmd So if you want to pass e.g. -v=1, your call probably should look something like: dateCmd := exec.Command(pwd + "/build", "-v=1")

Categories : Bash

Execute a shell command through ssh using PHP
Try phpseclib, that'll work. <?php include('Net/SSH2.php'); $server = "myserver"; $username = "myadmin"; $password = "mypass"; $command = "ps"; $ssh = new Net_SSH2($server); if (!$ssh->login($username, $password)) { exit('Login Failed'); } echo $ssh->exec($command); ?>

Categories : PHP

Simple c++ program fails to run as a scheduled-task (interactive/non-interactive issue?)
If i may answer my own question, This, appears to be some sort of security measure by windows to avoid receiving keyboard/mouse events from outside of users desktop (See here).

Categories : C++

python library package or interactive tool for networkX interactive visualization
Check out the Force example in NetworkX documentation: http://networkx.github.io/documentation/latest/examples/javascript/force.html The force example exports a NetworkX graph into JSON and further displays it in browser via D3.js library. Note that you are actually dealing with two problems here. The firstly problem is how you serialize the graph into a readable format, like JSON. NetworkX should provide you with this. The second problem is how you can display the serialized graph. For this task, you need an additional library, like D3.js. The cool thing here is that NetworkX does not enforce you to use any specific library. Besides D3.js, you might want to check out the following libraries: gexf-js (https://github.com/raphv/gexf-js) sigma.js (http://sigmajs.org/examples/gexf_exampl

Categories : Python

Execute shell command from service
If it's a windows app that requires the desktop, you're pretty much SOL. If it's a standard console application, you need to redirect standard input, standard output and standard error. You also need to set the ProcessStartInfo's UseShellExecute property to false: you service can't start the OS shell (cmd.exe) as that requires access to the desktop...and further, you can't redirect standard input with that property set to true. Standard input is normally wired up to the keyboard. Your service does not have access to the keyboard. Standard out and standard error are normally wired up to the cmd.exe console window. Once you have standard output and standard error redirected, you'll need to wire up handler to these Process object events: Exited. Raised when the process ends. OutputDataRec

Categories : C#

Execute shell commands with sudo via PHP
You have at least 4 options: Add the apache user to the sudoers file (and restrict it to run the one command!) In this case some security hole in your php-apps may run the script too (if they can include the calling php for example - or even bypass the restriction to your ip by using another url that also calls the script, mod_rewrite) Flag the script with the s bit Dangerous, don't do it. Run another web server that only binds to a local interface and is not accessible from outside This is my prefered solution, since the link calling the php is accessible by links from your main webserver and the security can be handled seperately. You can even create a new user for this server. Some simple server does the job, there are server modules for python and perl for example. It is not eve

Categories : PHP

exec a php to execute shell script
Your button is not actually doing anything. The problem is that your onclick attribute should contain javascript which will run when the button is clicked, not a redirect location. Use a form with a submit button instead like this. <form action="" method="get"> <input type="submit" name="run" value="Click Me!" /> </form> I notice in your question that you are also using post data in handling the form, in which case the above will not work. You need to submit the POST data at the same time as you run the script.

Categories : PHP

How to use command "at" to execute shell in MacOS
Using at Your use of at appears correct. The command is executed at 2 minutes in the future. The command is not executed repeatedly so that is why the file is not touched at any time other than the time that now + 2 minutes evaluates to. If you are having problems getting at to run commands make sure you have the atrun Launch Control agent enabled and runing. See man atrun for more information about that. Better Scheduled Command Execution If you just want something executed when you log in then System Preferences > Users > Login Items is a good place. Rename your shell scripts with .command as their extension though if you do that. I'm not sure if it is required but it's what the OS seems to prefer for such scripts. Otherwise try cron to provide more control over job execution or use

Categories : Osx

How to execute a oracle procedure from shell
Connect Oracle using SqlPlus, then run the procedure like this: execute package_name.procedure_name (parameters...) If you want to call sqlplus from within Windows shell: @echo execute some_procedure | sqlplus username/password@databasename (See this question ) On Unix, try this: echo "execute <some_procedure>" | sqlplus -s username/password@host:1521/service

Categories : Oracle

How Perl can execute a command in the same shell with it?
No, the Perl script will be run in a subprocess so it will not be able to affect the environment of the process that called it. There are various tricks you can use such as sourcing shell scripts (in the context of the current shell rather than a sub-process), or using bash functions and aliases, but they won't work here.

Categories : Perl

Can't execute a string as a shell command in elisp
I would suggest you to doublecheck both if executions are using same path, and therefore same ctags.exe. I think that might be the problem. You may want to use the full path to ctags.exe to make sure of that. My ctags (Linux) gives me the same error if I use the -Re option on a normal shell; that is what makes me think that way.

Categories : Shell

Shell Execute bring Window to front
Windows doesn't permit processes to snatch the foreground window unless the user starts them. This is to avoid things like persuading the user to type their bank details into the wrong window. However the current foreground process can pass permission to another process to do this. See AllowSetForegroundWindow for the details. To do this you have to provide the process id for the process that will become foreground and ShellExecute doesn't provide that. However, if you switch to using ShellExecuteEx you can get this from the hProcess member on the SHELLEXECUTEINFO structure. You can then call SetForegroundWindow in your new process and it will be permitted. Otherwise it just starts flashing on the taskbar. EDIT If your initial application is the foreground application and you start a su

Categories : C++

Execute Shell Script from python with variable
Like this ? subprocess.call(['test.sh', str(domid)]) Documentation is available on the python website

Categories : Python

How to execute a shell command in the current cmd.exe context?
When you start cmd.exe, you can set its environment path: var psi = new ProcessStartInfo("cmd.exe"); psi.UseShellExecute = false; psi.EnvironmentVariables["path"] = "mypath"; Process.Start(psi); Please prefer comment before downvote.

Categories : C#

Netbeans 7 - plugin to execute a shell command
I've been looking to do something similar, I wanted to add an action to the end of my build to auto-deploy the generated jar to my test server. I'm not sure if it's the best way, but the Exec Maven Plugin allows you to execute system commands. I updated my project configuration such that the nbactions.xml has the following: <action> <actionName>CUSTOM-SendToDevSrv</actionName> <displayName>SendToDevSrv</displayName> <goals> <goal>install</goal> <goal>process-classes</goal> <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal> </goals> <properties> <exec.args>-pw myPasswd "D:\pathTomyGenerated.jar"

Categories : Shell

How to add text to end of file via shell script which includes double quotes
Variables need to be placed around double quotes in order for them to be expanded. You also simply have to quote them with instances of double quotes inside it with i.e. ". echo "<VirtualHost *:8888> ServerName $devname DocumentRoot "$directory" <Directory "$direcotry"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>" >> /Applications/MAMP/conf/apache/vhosts.conf

Categories : Osx

how jump from staying for output of shell execute after run in an php script?
If i understand you wish to run a background process on a Windows box.Suggest try this... <?php shell_exec('start /b C:wampinphpphp5.4.3php.exe a.php'); shell_exec('start /b C:wampinphpphp5.4.3php.exe b.php'); ?>

Categories : PHP

how to execute a long shell with php ( by clicking button int this php page)
This is the ideal use case for a job queue. php job queues are covered in this question PHP Advance Job Queue I personally recommend Gearman

Categories : PHP

How to execute a shell command on the server side within javascript?
I don't believe this is possible with client-side JavaScript. Althought it's not really your question, you could do it if you were using NodeJS server-side (http://nodejs.org/api/all.html#all_child_process_exec_command_options_callback).

Categories : Javascript

Crontab Jobs didn't execute shell script
The cronjobs you schedule in your settings are not actually added to the crontab until you run python manage.py crontab add. RTD

Categories : Django

Using Shell to Check Whether a File Exists, and only if it does, Execute a Set of Commands
The confirm command has what you're looking for. capture confirm file "file.txt" if !_rc { # if the file exists, confirm will return error code 0 insheet using "file.txt" } Alternatively, you could put a capture before the insheet command, which will catch the syntax error. Check the [P] manual for more on capture and confirm.

Categories : Shell

Execute shell script in gruntfile and assign result to variable
Although I'm still unclear on why the method above is not working, and welcome any feedback, after a bit of research, I found shelljs, which I was able to use to solve my problem. Since shelljs can exec shell commands synchronously, I don't have to work with callbacks when I really want things to block: module.exports = (grunt) -> shell = require 'shelljs' envvar = shell.exec('./bin/get_envvar.sh', {'silent':true}).output grunt.initConfig pkg: grunt.file.readJSON('package.json') env: dev: ENV_VAR: envvar simplemocha: options: timeout: 30000 reporter: 'spec' compilers: 'coffee:coffee-script' all: src: ['Tests/**/*.coffee'] grunt.registerTask 'test', ['env', 'simplemocha'] A lot cleaner, too! References:

Categories : Node Js

apktool command in shell script does not execute from Java program
Well, in my experience, I would say that Java is not very fond of being ran by means of script. I did a quick google search. Try the ProcessBuilder, it looks perfect for this situation, in my opinion. I hope this helps you! :)

Categories : Java

Using Ruby 1.8.7, can I execute shell and capture PID, STDOUT, STDERR, status?
Unfortunately there isn't an easy way to do this. I tried PTY.spawn but sometimes it would fail to exec. If you can't use open3, then you can use FIFOs, but it gets a bit messy. Here's a solution I used on 1.8.7: # Avoid each thread having copies of all the other FDs on the fork def closeOtherFDs ObjectSpace.each_object(IO) do |io| unless [STDIN, STDOUT, STDERR].include?(io) unless(io.closed?) begin io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) rescue ::Exception => err end end end end end # Utilities for fifo method require 'tempfile' def tmpfifo # Use tempfile just to manage naming and cleanup of the file fifo = Tempfile.new('fifo.').path File.delete(fifo) system("/usr/bin/mkfifo",fifo) #puts "GOT: #{fifo} -> #

Categories : Ruby

unable to run commands in shell script after su mqm command,but able to run in putty?Pleae let me know how to execute.?
putty is interactive command line. Try the below. bash variables can be used. #!/bin/bash su - mqm -c "echo 'DISPLAY QLOCAL (<QUEUENAME>) CURDEPTH'|runmqsc QUEUEMANAGER"

Categories : Bash

Don't want php script to execute the shell command as apache user when it is executed through browser?
Sudo normally requires an interactive shell to enter your password. That's obviously not going to happen in a PHP script. If you're sure you know what you're doing and you've got your security issues covered, try allowing the Apache user to run sudo without a password, but only for certain commands. For example, adding the following line in your sudoers file will allow Apache to run sudo without a password, only for the gzip command. nobody ALL=NOPASSWD: gzip Adjust the path and add any arguments to suit your needs. Caution: There might still be complications due to the way PHP calls shell commands. Remember that it's very risky to allow the web server to run commands as root! Another alternative: Write a shell script with the suid bit to make it run as root no matter who calls i

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.