w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
output to command line from windows gui program
Most applications that need to accomplish this will create a *.com version of their app (which will sit alongside the .exe). All shortcuts will point to the .exe, but if the user happens to type the name on a command line, then the .com version will end up executing (as CMD will search for .com files before .exe files) The .com version is often a thin wrapper which will invoke the .exe and wait for it to finish or utilize shared .dll files, but it exists purely so that output can be funneled to the proper console window and won't "release" it until the application finishes. As an example, Microsoft's Visual Studio uses this approach: C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDE>dir devenv.* Volume in drive C has no label. Volume Serial Number is A482-59BA Directory

Categories : C

Getting a Dev-C++ built program to output UNICODE characters to the Windows command line
I have never used DEV-C++ IDE :-) However, after reading up on it a bit I see that dev-c++ version 4.9.9.3 uses gcc-3.5.4 mingw port. Which has universal character support status of "Done" see http://gcc.gnu.org/gcc-3.4/c99status.html for details. You have to change the IDE configuration such that the compiler uses -std=c99 as part of the compiler flags. Hopefully that will do the trick. I will try to fiddle with it on my own system and see how far we can get. Will update the answer if I find more clues :-)

Categories : C

Call java command line program from .net and return output of STDOUT to variable
Yes, use Process.StandardOutput (e.g., StreamReader.ReadToEnd among other possibilities). Be sure to set ProcessStartInfo.UseShellExecute to false, and ProcessStartInfo.RedirectStandardOutput to true.

Categories : Java

Piping output from 1 command to other command in an adb shell command line
One way is to create a shell script containing the commands you want and then run the shell script. Since the Android root filesystem is not writeable at run time (usually, unless you have rooted your device and remount it), you can copy the file to the removable (or emulated) storage, for example /sdcard. Then run the script using the command adb shell sh /sdcard/your-script-name. Because each script runs in its own subshell, both of your commands will be executed in the same shell on the device (you can confirm it with ps).

Categories : Android

Batch file/command to start a program through command line
I'll edit this if you respond to my comment but if you want to simply execute this command via a batch file (and you know nothing about batch files): Open a text editor (e.g.Notepad) Type in your command (e.g. c: andaotherfoldermyprogram.exe 10 20) Save the file as mybatchfile.cmd Double click the file (in Windows Explorer etc.)

Categories : Windows

different order of command line options in a command affecting my output
getoptlong() is doing exactly what it is supposed to do. The format-string "d:g:hv" implies that the parameters d and g require a value. Anything specified following a command-line parameter is consider a value being passed to it. You should run your program as $program --download file --version Checkout this detailed example demonstrating the various aspects of using getoptlong(). How rm can handle the differing position of its cmd-line params? Apparently because rm's parameters (r, v etc.) do NOT accept any values as arguments. Thus directory does not get passed to any of them but rather is a separate cmd-line argument on its own. You can confirm this from the source-code of rm. To do something similar for your program, you will need to modify the optstring to "dghv" a

Categories : C

"UnicodeDecodeError : 'ascii' codec can't decode byte" when handling Chinese language command line arguments with ElementTree
byte strings and unicode strings are exchangeable only when there are only characters < 128. The elements sys.argv contents are byte strings in python 2.x. Furthermore, it seems that they are encoded in GB2312, not UTF-8. Thus you need to be explicit: a_value = sys.argv[1].decode('GB2312') b_value = sys.argv[2].decode('GB2312')

Categories : Python

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 get command line output snippet if I know the line number in Windows?
Here's one way of doing it with a batch file, although it's not a very elegant solution. @echo off setlocal set currentservice="" set servicestate="" sc query state= all > services.txt for /f "delims=:; tokens=1,2" %%a in (services.txt) do call :findservice "%%a" "%%b" del services.txt echo %servicestate% endlocal goto :end :findservice if not %1 == "SERVICE_NAME" goto :findstate set currentservice=%2 goto :end :findstate if not %1 == " STATE " goto :end if not %currentservice% == " Telnet" goto :end set servicestate=%2 goto :end :end It first writes out the result of the sc query to a temporary file (services.txt). It then uses a for loop to process each line of that file. When it find a line starting with SERVICE_NAME, it saves the value of that name in t

Categories : Windows

Get system command output in C program
Ok, I was confused in my other answer. In any case, the philosophy in this answer is the same. You can use directly the popen function. Then you have something like this: int numOfCPU; FILE *fp = popen("grep -c ^processor /proc/cpuinfo", "r"); fscanf(fp, "%d", &numOfCPU); pclose(fp); I hope it will be useful.

Categories : C

PyQt4 `QCoreApplication.arguments()` returns 'unknown' when I pass non-ASCII command line arguments
The encoding for QApplication is Latin-1, and you need it to be UTF-8. To get around this, you may manually encode the arguments using .encode('utf-8'), before passing them to QApplication.

Categories : Python

Web browser command line program
You haven't completely finished the request. You need two newlines, as otherwise it just looks like you're still writing out the request headers. Add an extra println and you may be okay, although as HTTP specifies CRLF for the line ending, I would actually use print rather than println, and put at the end of each line explicitly. (I'd also avoid using PrintWriter, personally - swallowing exceptions is bad...)

Categories : Java

Command line arguments in F# program?
If you don't want to use the args array passed to your main function then you could use System.Environment.GetCommandLineArgs() instead. Note this will include the name of the program being run as the first item, unlike the args array given to your main function. open System [<EntryPoint>] let main(args) = printfn "args: %A" args printfn "env.cmdline: %A" <| Environment.GetCommandLineArgs() 0 Run as args.exe 1 2 3 4: args: [|"1"; "2"; "3"; "4"|] env.cmdline: [|"args.exe"; "1"; "2"; "3"; "4"|]

Categories : Dotnet

How to call a command line program in WiX
I would recommend using the ShellExecute custom action from the WiX toolset. Here is the sample code: <Property Id="WixShellExecTarget" Value="[#myapplication.exe]" /> <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" /> Change the Value of property WixShellExecTarget to cmd.exe /K &quot;C:OpenOffice.org3programunopgk.com list --shared&quot; and it should work.

Categories : Wix

How is interacting with a prompt of a third party command line program different from a Windows Command prompt?
Most likely the program starts its own shell and does no longer interact with the original one. (You would notice this if the program opens a new window) Or the program needs some specific library to be present to be able to interact with a shell (readline seems to be the case here) and that is not present in your Java Environment. As a quick hack you might try to start bash (or cmd) that then starts the tool. bash and cmd have readline library. I don't have a windows ready here but as a guess just try to call your program like cmd urjtag.exe instead of just urjtag.exe that way you start a cmd process (with that you can interact) and that cmd starts the urjtag.exe where you already know that it can interact with. Either way the problem lies in the way the program you want to call intera

Categories : Java

Getting command line parameters from an assembly program
With the help from @Michael, I was able to track down the problem. Using %ebp as argv as @Michael suggested (he used %eax though). Another problem was that I needed to compare the value of (%ebp) with 0 (the null terminator) and end the program at that point. Code: movl 8(%esp), %ebp /* Get argv. */ pr_arg: cmpl $0, (%ebp) je endit pushl %ecx pushl (%ebp) pushl $output2 call printf addl $8, %esp /* remove output2 and current argument. */ addl $4, %ebp popl %ecx loop pr_arg ret

Categories : Linux

How to pass command line arguments to a c program
In a Windows environment you just pass them on the command line like so: myProgram.exe arg1 arg2 arg3 argv[1] contain arg1 etc The main function would be the following: int main (int argc, char *argv[])

Categories : C++

Program that is dependent on command line arguments
sys.argv is a list of the arguments, so you want to check to see if the length is equal to one (sys.argv[0] will always be the name of the script): if len(sys.argv) == 1: # no arguments provided

Categories : Python

How do I test a command-line program with PHPUnit?
One way is to use the backtick operator (`) to capture the output of the program, then examine that output. This works well under Unix/Linux-style OSes, as you can also capture error outputs like STDERR. (It is more painful under Windows, but can be done (especially using Cygwin).) For example: public function testHelp() { $output = `./add-event --help 2>&1`; $this->assertRegExp( '/^usage:/m', $output, 'no help message?' ); $this->assertRegExp( '/where:/m', $output, 'no help message?' ); $this->assertNotRegExp( '/where event types are:/m', $output, 'no help message?' ); } You can see that both STDOUT and STDERR were captured to $output, then regex assertions were used to test whether the output resembl

Categories : PHP

wxpython GUI running a command-line program
I wrote up an article where I did something along the lines that you're talking about. I needed to run ping and traceroute and capture their output in real-time. Here's the article: http://www.blog.pythonlibrary.org/2010/06/05/python-running-ping-traceroute-and-more/ Basically you need to redirect stdout to a text control and then do something like this: proc = subprocess.Popen("ping %s" % ip, shell=True, stdout=subprocess.PIPE) line = proc.stdout.readline() print line.strip() As you can see, I use subprocess to start ping and read its stdout. Then I use the strip() command to remove extra whitespace from the beginning and end of the line before I print it out. When you do the print, it gets redirected to the text control.

Categories : Python

How can I get shell command output to line up?
You can't do it the way you're going about it. Connection to host.com closed. is output by the command you called, and not returned via STDOUT, which you could capture with backticks. The problem is the use of backticks. They don't capture STDERR, which is most likely what ssh is using when it outputs its status. The fix is to use Open3's methods, such as capture3 which will grab the STDOUT and STDERR streams returned by the called program, and let you output them programmatically, allowing you to align them: stdout_str, stderr_str, status = Open3.capture3([env,] cmd... [, opts]) You should also look at Ruby's printf, sprintf or String's % method, which calls sprintf. Using % you can easily format your strings to align: format = '%7s %s' puts format % ["------>", "Executing:"] p

Categories : Ruby

innobackupex - get output from command line
I don't mean to step on @RudyVisser's answers in comments, but here's another solution: $syntax = 'innobackupex --user="'.$mysql_user.'" --password="'.$mysql_pass.'" --databases="'.$mysql_db.'" --stream=tar ./ | gzip -c -1 > /var/bak/2013-08-09-1431_mysql.tar.gz ; echo $?') $exit_status = shell_exec($syntax); The echo inside the command should report the exit status of innobackupex, which is 0 if the backup was successful, and non-zero if there was an error. http://www.percona.com/doc/percona-xtrabackup/2.1/xtrabackup_bin/xtrabackup_exit_codes.html PS: Percona XtraBackup also has a --compress option that uses the qpress algorithm, known to be very fast. I mention this because I notice you're using gzip -1 presumably for better performance.

Categories : PHP

Running a Java program in Eclipse as if from command line
You need to go to: Run Configuration > Argument > Program argument. Then copy and paste "inputFile.txt" "inputFile2.txt" inside the box.

Categories : Java

How to run python program on command line with different input possibilities
You'll have to make all arguments optional and validate them yourself: ap=argparse.ArgumentParser() ap.add_argument('-c', required=False) ap.add_argument('a', nargs='?') ap.add_argument('b', nargs='?') args = ap.parse_args() if (args.c is not None): # process c elif (args.a is not None and args.b is not None): # process a and b else: # validation errors If you were willing to make a and b a single named parameter instead of positionals, you could use mutual exclusion to do this for you. Mutually exclusive groups require all parameters in them to be optional, and named parameters can only be required. ap=argparse.ArgumentParser() g = ap.add_mutually_exclusive_group(required=True) g.add_argument('-ab', nargs=2, required=False) g.add_argument('-c', required=False) args =

Categories : Python

Passing Integer Parameters to a C Program using the Command Line
You seem to be assigning x and y the return value of sscanf, which means that after it has read the input and stored the values to the appropriate variables, you are then overwriting them. Try removing x= and y= from those lines.

Categories : C

mysql command line to vertical output
I'm not sure this is a good solution, but if explicitly using egrep is annoying, you could define a shell function to launch mysql with the desired pager. Assuming you're using a bash (or compatible): # define a shell function to launch mysql with the required _pager_ sh$ mysql() { `which mysql` $* --pager="egrep -v '^*.**$'" ; } [ ... ] # launch mysql "as usual" (in reality, this is the shell function that is invoked) sh$ mysql -u user -p -h mysql-host mydb Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 67 Server version: 5.1.49-3 (Debian) -- Use mysql normally -- but the "egrep pager" will remove the "star lines" mysql> select * from TG col1: w col2: x col3: 0.4 1 row in set (0.00 sec) As I said before, this is not a perfect

Categories : Mysql

How to suppress a program GUI when starting a process from Windows command line?
Some windows programs allow them to be run from the command line with the GUI suppressed it varies between programs. Either check the specific programs website/help/manuals/usergroups or try running from the command line with the -h -? -help or --help flags - those that do allow it normally have command line help - and look for a quiet option, (often -q --quiet or --silent are used). Also some programs are actually GUI front ends for command line back end processing so there may be a different command to run on the command line altogether - the documents are usually the place to look for that. Sorry this is effectively a long version of RTFM but there is really no completely general answer that I know of. Update This answer (from J.F. Sebastian's comment) put me on the track of: star

Categories : Python

How can I detect the first instance of a command-line Dart program to start?
Detecting if a instance of a program is the first instant is often done using a mutex. But Dart don't have any syncronisation methods build in. An alternative approach would be using a network port on the loopback interface. Choose a fixed port, if a instance is started, check if you can listen on the port. If the port is not available, another instance is already running. As a positive side effect you can use the connection to communicate between the instances of your application.

Categories : Dart

How do I statically link to a lib when creating a command line program in xcode?
I got this to work. This seems to be a libconfig build issue, maybe expected behavior but it surprised me. I was linking to libconfig.a, but it appears that libconfig.a was linking to libconfig.dylib. I reconfigure libconfig and reinstalled it. ./configure --disable-shared make clean make make install

Categories : C

Boost program options- crash on parsing command line
Looking at the tutorial, I don't see commas between the options. ie: desc.add_options() ("help", "produce help message") // no comma here! ("compression", po::value<int>(), "set compression level") ; Try removing the commas you have at the end of each option.

Categories : C++

How to open any command line program through a swing GUI and pass commands to it?
I would actually avoid passing through the command prompt and directly invoke your command line program. All you have to do is to find where your program is located. A few things to take into consideration: You should execute your command outside the EDT (Event dispatching thread) to avoid GUI-freeze (SwingWorker will do a very good job at it) Rather use ProcessBuilder than RuntimeExec Here is an example of such code which invokes the command java -version (this is only for the example of using the ProcessBuilder API): import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; import java.util.concurrent.ExecutionException; import javax.swing.JButton; impo

Categories : Java

How to make program accept glob (wildcards) at command line?
The easiest way to do this is to convert the command line parameter into a regular expression. See glob pattern matching in .NET for an example on how to convert the command line argument into a regular expression.

Categories : C#

How to write a command line program which can be accessed by a separate frontend?
A simple, probably naïve way could be to structure your CLI program such that its main function accepts your command line arguments, so that you could import it and call it with the options set in the GUI. I've never tried it, my guess is that it could work with simple "pure" CLI programs (ie, you run it, it does its jobs, and only then prints its output), but could get unwieldy with interactive program needing to prompt the user or with a lot of output.

Categories : Python

running SWF from the command line and getting trace output to the console
You can use the command line debugger, fdb to see console output. First, compile a debug SWF: mxmlc -debug=true myApp.mxml Then launch the debugger: java -jar ../lib/fdb.jar Then you can either launch your app in the standalone Flash Player or in a browser. When you see the (fdb) prompt, use the run debugger command to start your app. You have several choices: run <path to SWF> (launch SWF in the standalone Flash Player) run <url to SWF> or run <path to HTML file that embeds SWF> (launch in browser)

Categories : Misc

Command line utility in Unix to output hashes
How about sha256sum for example, or better still, shasum e.g. $ shasum -a 256 < myfile.txt md5sum performs the same using the MD5 algorithm. I'm sure it would be trivial to wrap all of these with one shell script (e.g. Perl) that uses an option to select the binary to pipe into. Note that those suggested above all work in a broadly similar fashion so a wrapper script would be relatively easy.

Categories : Security

put awk or grep output to command line arguments in bash
In bash, you cannot set positional parameters in a way that the caller can read that value. If you want to 'return' a string from a function, you must write it to stdout, like so: function myfunc() { echo "test" } VAR=$(myfunc) When the above code is run, VAR will contain the string 'test'.

Categories : Bash

How to reverse command line compilation error output?
Pipe the output to more on command-line or better use an IDE like Eclipse. javac file.java | more Now press space bar to let the output scroll (or enter for line by line) if it's more than one screen page.

Categories : Java

How to test RSpec tests output in command line
One way would be to refactor the code so that it takes an IO object as input and gives its output by calling puts on that. In normal use, use $stdout but in your tests use a StringIO object. If that is not feasible, you might consider inside your tests defining a special puts method in the class being tested. This would hide the real puts method.

Categories : Ruby

Getting output from running command line app in Inno Setup
With TLama pointing to the progress bar messages I was able to solve the problem. At first I needed to pass the progress bar handle from Inno to my C# app. For this I created a function that would return me the int-pointer as a string function GetProgressHandle(Param: String): String; begin Result := Format('%d',[WizardForm.ProgressGauge.Handle]); end; and use it in the Run-section when calling my app: [Run] Filename: "{app}myApp.exe"; Parameters: "{code:GetProgressHandle}"; .... In C# I read the int-pointer from the console arguments and use it to create an IntPtr: IntPtr pointer = new IntPtr(Int32.Parse(args[0])); To send the messages to the progress bar I imported user32.dll and re-defined the needed constants, that normally can be found in commctrl.h: [DllImport("user32.dl

Categories : C#

PHP+cURL disable command line progress output
From the manual refering to CURLOPT_NOPROGRESS: CURLOPT_NOPROGRESS TRUE to disable the progress meter for cURL transfers. Note: PHP automatically sets this option to TRUE, this should only be changed for debugging purposes. Looks like the progress has been explicitly turned on. Check you code for that option. In any case, if you want to explicitly disable it again, curl_setopt($curlHandle, CURLOPT_NOPROGRESS, true) should do the trick. Update: If you instead do something like exec("curl http://example.com") you should a) think about what you're doing and b) run curl -s to disable the progress. PHP's streams have support for http, so you can just use file_get_contents, copy et al.

Categories : PHP



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