w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Using C# to execute PowerShell script with command line args using V2 methods
Answering my own question here. It looks like the right approach would be for my application to function as a PowerShell Host http://msdn.microsoft.com/en-us/library/windows/desktop/ee706610(v=vs.85).aspx Use of PowerShell V2 objects is defined here: http://msdn.microsoft.com/en-us/library/windows/desktop/system.management.automation.powershell(v=vs.85).aspx

Categories : C#

Using ProcessBuilder to execute a python script with command line options
Just give them as separate strings in the array, instead of combining the last two into "val_31 val_32": String[] command = {"script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31", "val_32", }; Otherwise it will escape the space in between val_31 and val_32 because you are telling it that they're a single parameter. Incidentally, you can also use the varargs constructor and skip having to create an array, if you want: ProcessBuilder probuilder = new ProcessBuilder( "script.py", "run", "-arg1", "val1", "-arg2", "val2" , "-arg3" , "val_31", "val_32");

Categories : Java

Command works in command line but gives 'no such file or directory' in bash script
Remove the quotes around line 8. Like this: ./optAlg.exe "$inputFile" 500 2>&1 > "output/$outputFile" By placing quotes around the whole line you tell bash to execute a command which is called exactly ./optAlg.exe $inputFile 500 2>&1 > output/$outputFile and of course there is no such command. In reality you want to run ./optAlg.exe with parameters. Do not forget to place quotes around the variables because otherwise filenames that have whitespace characters are going to be passed as several arguments. Please read about arguments. And you can read about common pitfalls as well.

Categories : Bash

how to read multiline output command line by line, in a shell script?
Maybe I found a different solution, where I can use variables also outside the loop I have to change the default IFS to newline echo Searching for android virtual devices ... IFS=$' '; for l in $(${PROGDIR}/android list avd) ; do VAR1=$(echo $l | cut -d: -f1 | sed -e 's/s*//'); #sed removes trailing blanks if [ $VAR1 == "Name" ]; then NUM_AVD=$(($NUM_AVD+1)); fi; done echo "NUM_AVD=$NUM_AVD" In this case NUM_AVD is correctly 2

Categories : Shell

How to execute an external command in Vim script?
You can use the :! vim command. For example, to echo 'Hello, World!' from inside vim (and therefore from within a vim script, also), type :! echo 'Hello, World!' in vim. Or, in a vim script, you can put just ! echo 'Hello, World!' The reason you need the before the ! is because vim performs special handling of ! characters in the argument of a ! command. If you were running a command that does not include any ! character, then you do not need to escape it. If you want to read more in depth about this, you can type :help :! in vim, as @FDinoff said.

Categories : Vim

bash shell script error works on command line, not in script
Variables are supposed to contain data, and bash treats them as data. This means that shell meta-characters like quotes are also treated as data. See this article for a complete discussion on the topic. The short answer is to use arrays instead: ASCIIDOC_OPTS=( --asciidoc-opts='-a lang=en -v -b docbook -d book' ) DBLATEX_OPTS=( --dblatex-opts='-V -T db2latex' ) cmd=(a2x -v -f pdf -L "${ASCIIDOC_OPTS[@]}" "${DBLATEX_OPTS[@]}" "$1".asciidoc) # Print command in pastable format: printf '%q ' "${cmd[@]}" printf ' ' # Execute it "${cmd[@]}" Make sure not to use eval: eval "$cmd" #noooo This will appear to work with your code as you posted it, but has caveats and security problems.

Categories : Bash

The DB2 SQL script is hanging in shell script, but working successfully in command line
Are you sure DB2 is blocking? Did you put a semicolon between commands db2 CONNECT TO ktest4 ; db2 -v -f /tmp/sql/application_system/opmdb2_privilege_remove.sql.5342 In order to trace the execution, I advise you to put some output, in order to detect where is it blocking date ; db2 -r /tmp/output.log CONNECT TO ktest4 ; db2 -r /tmp/output.log values current timestamp ; db2 -r /tmp/output.log -v -f /tmp/sql/application_system ; db2 -r /tmp/output.log values current timestamp ; db2 -r /tmp/output.log terminate With a command like this, you will save all outputs, and then you could check where is the error.

Categories : SQL

How do I execute a photoshop droplet from the command line on mac osx?
Answer: Opens photoshop and executes the droplet on the image: NOTE: '--args' omitted: open -a /full_path/watermark_foodlab_landscape_W600 /full_path/y020_Pork_Terrine_Orange_Paste_Bread.JPG Thanks Frederick that worked a treat!! Combinations tried: Opens photoshop: open /full_path/watermark_foodlab_landscape_W600 Opens photoshop and opens image in preview: open /full_path/watermark_foodlab_landscape_W600 /full_path/y020_Pork_Terrine_Orange_Paste_Bread.JPG Opens photoshop: open -a /full_path/watermark_foodlab_landscape_W600 --args /full_path/y020_Pork_Terrine_Orange_Paste_Bread.JPG Opens photoshop and opens image in preview: open ./watermark_foodlab_landscape_W600 ./y020_Pork_Terrine_Orange_Paste_Bread.JPG Opens photoshop: open ./watermark_foodlab_landscape_W600 --args

Categories : Ruby

Batch - Execute Macros from command line
I've continued looking for it, and I found an answer to execute the macro. We should open the repertory in cmd where is the file with the macro ,put the address of the exe, write the name of it and the reference of the macros. I'll do an example: "C:Program FilesOpenOffice.org 3programsoffice.exe" FileName.ods "macro:///Standard.Module1.MacroName" if wanted directly from matlab, is just use the system('') command.

Categories : Csv

Execute command in variable bash script
Since I'm running a shell script, it uses a sub-shell so it cannot access the parent shell's environment. Problem solved running the shell script in this way: . ./script.sh

Categories : Shell

Execute process from the windows command line in Python
By trying your code it prints out PreprocessedTufts8199PLAIN.txt.xml file name. I'm not sure if the .txt.xml extension was the desired result. If your file has only .xml extension, then you're not stripping away the original .txt header. Try to change this line: outFile = file(inFile[(str(inFile).rfind('\'))+1:] + '.xml') Into this code: fnameext = inFile[(str(inFile).rfind('\'))+1:] fname,fext = os.path.splitext(fnameext) xmlfname = fname + '.xml' xmlfpath = os.path.join(".", xmlfname) print "xmlfname:", xmlfname, " xmlfpath:", xmlfpath print "current working directory:", os.getcwd() outFile = open(xmlfpath, "r") Answer for extension stripping.

Categories : Python

how can execute nagios commands from command line in linux
You actually have the answer in your config - just execute in shell: /usr/lib/nagios/plugins/check_http -H site1.dreaddomain.com You may add -v for verbose output. Nagios is only a scheduler and executes commands at specified intervals. Then reports the state based on response.

Categories : Linux

Command to read a file and execute script with psql
For an SQL script you must .. either have the data inlined in your script (in the same file). or you need to utilize COPY to import the data into Postgres. I suppose you use a temporary staging table, since the format doesn't seem to fit the target tables. Code example: How to bulk insert only new rows in PostreSQL There are other options like pg_read_file(). But: Use of these functions is restricted to superusers. Intended for special purposes.

Categories : Postgresql

Bash script execute command on multiple servers
ideally just put the commands in quotes like this: ssh admin@10.x.x.x '/sbin/arp -an | grep lanx' > lanx or ssh admin@10.x.x.x '/sbin/arp -an' | grep lanx > lanx The other problem might be the user admin on your machine does not have arp in PATH (is he root? arp is usually in /sbin/ and /sbin/ is usually not in PATH of a regular user.

Categories : Linux

How to execute command line ffmpeg commands programatically in android?
Recently I came across the similar problem. My solution is to simulate a command line in Java program. Firstly, I add a function to the file "ffmpeg.c": int cmd_simulation(int argc, const char** argv) { OptionsContext o = { 0 }; // int64_t ti; reset_options(&o, 0); av_log_set_flags(AV_LOG_SKIP_REPEATED); parse_loglevel(argc, argv, options); if(argc>1 && !strcmp(argv[1], "-d")){ run_as_daemon=1; av_log_set_callback(log_callback_null); argc--; argv++; } avcodec_register_all(); avfilter_register_all(); av_register_all(); avformat_network_init(); //show_banner(argc, argv, options); term_init(); parse_cpuflags(argc, argv, options); /* parse options */ parse_options(&o, argc, argv, options, opt_output_file); if (nb_output_files <= 0 && nb

Categories : Android

How can I execute mysql query from command line on Server 2008 R2?
Usually the mysql command-line tool will get you there, where you may need to provide any credentials to get access. This comes with most installations of MySQL, but you'll need to check that it's located in your PATH or it might not be found. It may be easier to use the MySQL Workbench tool to connect and run queries instead.

Categories : Mysql

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

bash: get literal parameters passed to a script and execute them as a command
You are on the right track, and almost got it. You just need to use "$@" instead of $@. Here's a summary of what $* and $@ do, with and without quotes: $* and $@ paste in the positional arguments, then tokenise them (using $IFS) into separate strings. "$*" pastes in the positional arguments as one string, with the first character of $IFS (usually a space) inserted between each. "$@" pastes in the positional arguments, as a string for each argument. Examples: $ set foo bar "foo bar:baz" $ printf "%s " $* foo bar foo bar:baz $ printf "%s " $@ foo bar foo bar:baz $ printf "%s " "$*" foo bar foo bar:baz $ printf "%s " "$@" foo bar foo bar:baz Here's what changes when you set $IFS: $ IFS=: $ printf "%s " $* foo bar foo bar baz $ printf "%s " $@ foo bar foo bar baz $ printf "%s " "$*" f

Categories : Bash

trying to execute a bash command in my apache server through my php script but getting error
You have to escape your double quotes in the string: exec("awk -F: '{printf "www.example.com/2/tasks.php?account=%s%%3A%s\n" ,$1, $2 }' < /opt/lampp/htdocs/$filename > /opt/lampp/htdocs/2.txt");

Categories : PHP

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

how to execute data command that returns a result set in Vb.net SSIS Script Task
To store results in string array. You can use this sample block of code in place of those commented code and adjust the sql statement accordingly. you can store these results in DataTable or in Multidimentional array also. sqlComm = New System.Data.SqlClient.SqlCommand("select Column1 from table ", sqlConn) Dim sqlReader As System.Data.SqlClient.SqlDataReader Dim arrList As New ArrayList() sqlReader = sqlComm.ExecuteReader Do While sqlReader.Read arrList.Add(sqlReader.GetString(0)) Loop

Categories : Vb.Net

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

How do you execute .exe files as administrator or give a run as admin option within a batch file in command line
Use PowerShell or VBScript from Batch to elevate privileges (via ShellExecute). Note that the runas verb is undocumented (not officially supported). PowerShell Method PowerShell -Command (New-Object -com 'Shell.Application').ShellExecute('program.exe', '', '', 'runas') VBScript Method set "VB=%Temp%Admin.vbs" > "%VB%" echo Set UAC = CreateObject^("Shell.Application"^) >> "%VB%" echo UAC.ShellExecute "program.exe", "", "", "runas" if exist "%VB%" "%VB%"

Categories : Batch File

Run R script from command line
You need the ?Rscript command to run an R script from the terminal. Check out http://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html Example ## example #! script for a Unix-alike #! /path/to/Rscript --vanilla --default-packages=utils args <- commandArgs(TRUE) res <- try(install.packages(args)) if(inherits(res, "try-error")) q(status=1) else q()

Categories : R

R script from command line
Rscript is very handy (R CMD BATCH is the old way to ) specially under windows, But generally under I create a batch file to avoid all path's headache. For example say launcher.bat: @echo off C: PATH C:ProgrammeRR-3.0.1in;%path% cd PATH_TO_YOUR_RSCRIPT Rscript tryCatch.R 1 pause And open a console(using cmd) , go where you have stored your launcher.bat and launch it. Or from the R cosnole using shell: shell('path_to_launcherlauncher.bat')

Categories : R

Run PHP script from command line and max_execution_time
Yes. See http://php.net/cli and there specifically http://php.net/commandline.differences

Categories : PHP

Command Line PHP Script not executing correctly
use this mysql_query() instead of mysql_subquery() you should use PDO or mysqli instead of mysql. mysql is already deprecated

Categories : PHP

Stop bash script without command line
I think it is a little bit overcomplicated. Actually you do not need to start bash as it is started when You start ./executeServer.sh. Add executable rights to ./executeServer.sh and start it as it is. And do not need to start it in the background, as it already starts Server in the background in the script.

Categories : Bash

Shell script array from command line
This tcl script uses regex parsing to extract pieces of the commandline, transforming your third argument into a list. Splitting is done on whitespaces - depending on where you want to use this may or may not be sufficient. #!/usr/bin/env tclsh # # Sample arguments: 1 2 {element1 element2} 4 # Split the commandline arguments: # - tcl will represent the curly brackets as { which makes the regex a bit ugly as we have to escape this # - we use '->' to catch the full regex match as we are not interested in the value and it looks good # - we are splitting on white spaces here # - the content between the curly braces is extracted regexp {(.*?)s(.*?)s\{(.*?)\}s(.*?)$} $::argv -> first second third fourth puts "Argument extraction:" puts "argv: $::argv" puts "arg1: $first" puts "arg2: $s

Categories : Arrays

How do I get a Blender exporter script to run from the command line?
I finally figured this out and thought it would be a good idea to come back and share the answer. First here is the file that works. # Required Blender information. bl_info = { "name": "My Exporter", "author": "", "version": (1, 0), "blender": (2, 65, 0), "location": "File > Export > Test (.tst)", "description": "", "warning": "", "wiki_url": "", "tracker_url": "", "category": "Import-Export" } # Import the Blender required namespaces. import sys, getopt import bpy from bpy_extras.io_utils import ExportHelper # The main exporter class. class MyExporter(bpy.types.Operator, ExportHelper): bl_idname = "export_scene.my_exporter"; bl_label = "My

Categories : Python

Running Perl Script from Command Line?
According to the documentation: Perl Express is not tied to a specific Perl port and should work with any build for Windows. and the system requirements: Windows 98/Me/2000/XP/2003, Perl Interpreter So you, presumably, have a separate Perl distribution already installed somewhere. That should have a perl.exe executable that you can use to run your script.

Categories : Perl

Use value from javascript on html page to execute python script
Here is a simple Python script that pipes the output of a locally executed command (dir on a Windows computer in this case) via a web request (using the excellent web.py library): import web from subprocess import check_output urls = ( '/', 'index' ) app = web.application(urls, globals()) class index: def GET(self): return '<pre>'+check_output('dir', shell=True)+'</pre>' if __name__ == "__main__": app.run()

Categories : Python

Content script doesn't re-execute on page reload
Some links in facebook call ajax functions, so most of time clicking on a link in facebook doesn't change the page, just loads content via ajax. So your content script executes only once. There are two possible solution, You can also add a DOM change listener like DOMSubtreeModified, and run the code every time when content is changed. You can add CSS code to page, so it doesn't need to be run every time even if page is changed via ajax. Like this, manifest.json { "name": "NewsBlock", "description": "NewsBlock - Facebook Newsfeed Hider", "version": "1.0.0", "background": { "scripts": ["background.js"] }, "permissions": [ "tabs", "http://*/*", "https://*/*", "storage" ], "browser_action": { "default_title": "NewsBlock", "default_icon": "icon.png"

Categories : Facebook

How to execute tcl script from php page and retrive the output back
Your tcl script should write on stdout: set a 10 set b 20 set c [expr {$a + $b}] puts $c If your tcl script is supposed to output multiple lines: e.g.: puts $c puts $c puts $c you can capture them in a PHP array: e.g.: $array = array(); function print_procedure ($arg) { echo exec("/opt/tcl8.5/bin/tclsh test.tcl",$array); //print_r($array); }

Categories : PHP

Linux XML Editing from Command Line / Shell Script
I wouldn't try to use sed to edit XML. Unless there is some constant to match on (that lets you decide if you are on a /1 or /2) it'll be hard (I would say impossible, but some sed guru will chime and and prove me wrong...) If you can't install stuff, something like an awk or perl script that lets you keep a minimum of state you work better than sed.

Categories : Xml

How can I assign a filename passed from command line in a C script?
First you should check that the argument exist, by checking argc. Then simply assign it to a char * if you can't use argv[x] directly (which you should be able to do).

Categories : C

Script working fine from command line, but not from crontab
Take a look at /apps/ins/.profile and the files it executes - such files usually have a conditional that exits the script early if it's not run in a terminal. For example: [ -z "$PS1" ] && return This may change the behavior of your script (or even skip it, if exit is used in place of return). At the very least, you will miss aliases, possible PATH changes, and other things set up in the .profile script, which will affect if and how your main script is run. Try to comment the line . /apps/ins/.profile in the script above, and see if it still runs in the terminal. If it does, run it like that from crontab and see if it fixes your problem.

Categories : Linux

Command line script run in background goes in stopped state
Usually, the process what do you send to background with the & and the script waiting for an input from the terminal, going into the stopped state. E.g. have a bash script valecho: #!/bin/sh read val echo $val runnig it as: ./valecho & the script will stop. When run it as echo hello | ./valecho & will correctly run and finish. So, check your php - probably wants some input from the stdin Edit - based on comment: i'm not an php developer - but just tried the next script (p.php) <?php while(true){    echo 'hi '.time()." ";    sleep(3); } ?> with the command: php -f p.php & and running nicely... so... sry for confusion...

Categories : Linux

How to open a window from the command line within a Python script?
You can use subprocess module. subprocess is a newer way to spawn processes rather than using os.spawn*() or os.system(). In your case: import subprocess subprocess.Popen(["ds9"]) This should run ds9 in background. See the documentation here.

Categories : Python

Shell script call command line application
You can use echo, but in a pipeline. echo 1000 | java myProgram If you want to send a file, you can use cat: cat file.txt | java myProgram

Categories : Java



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