command

Command line parameters c++ [duplicate]

﹥>﹥吖頭↗ 提交于 2019-11-29 18:51:59
This question already has an answer here: Command-line Parameters in C program? 4 answers I have been asked to create a c++ program that "accepts a command line parameter and outputs the number of prime numbers less than this value; if no parameter is given, output just std::endl to std::cout " I understand how to look up prime numbers but I am unsure what a "command line parameter" is and how it ties into the work. Also, I think if there is no parameter given, you just std::cout << std::endl ? I have tried to work out what a command line parameter is but cannot find any meaningful resources

WPF Listbox and Select All

梦想与她 提交于 2019-11-29 17:36:52
问题 I want to create a simple ListBox and have SelectAll as a context menu item. However it seems that ListBox has some sort of inbuilt handling for SelectAll that I can't get working, but is interfering with my attempt to implement SelectAll. My entire XAML is this: <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Window.CommandBindings>

run a java program

女生的网名这么多〃 提交于 2019-11-29 17:35:12
I want to run a java program using shell script. The java program is in p2 directory and its name is maxconnect4 and I have already compiled it, the class name is maxconnect4. I write the shell commands like this: java p2/maxconnect4 arg1 arg2 arg3 This shell command does not work. It give an error: Exception in thread "main" java.lang.NoClassDefFoundError: p2/maxconnect However, I compile the java program in this way: javac p2/*.java, and it works. Just use java -cp p2 maxconnect4 arg1 arg2 arg3 . -cp sets the classpath of the JVM. Edit: I assume you don't use a package for maxconnect4.

Bash conditional based on exit code of command

你说的曾经没有我的故事 提交于 2019-11-29 17:00:47
In Bash, I would like an if statement which is based of the exit code of running a command. For example: #!/bin/bash if [ ./success.sh ]; then echo "First: success!" else echo "First: failure!" fi if [ ./failure.sh ]; then echo "Second: success!" else echo "Second: failure!" fi success.sh #!/bin/bash exit 0 failure.sh #!/bin/bash exit 1 This should print out: First: success! Second: failure! How would I achieve this? Thanks! Just remove the brackets: #!/bin/bash if ./success.sh; then echo "First: success!" else echo "First: failure!" fi if ./failure.sh; then echo "Second: success!" else echo

Some Copy command in windows to copy from current location to specified location

若如初见. 提交于 2019-11-29 16:20:52
So, I have started with this: copy | dir /s /b | find "myFile" C:\Destination but the problem is that the destination is not visible in this command. It only sees the first part of the command up untip C:\Destination. Is there a way I can search for a file and copy it? I have also tried this thins: SET source = dir /s /b | find "myFile" SET destination = %CD% copy %file% %destination% but it doesn't work. At some point even trying to set a variable that points to the curent directory ( %CD% ) doesn't work. Thanks in advance! PS: I'm looking for a solution that would work without installing

Cmd - get variable in variable name

陌路散爱 提交于 2019-11-29 15:27:45
I have a problem about variable in variable ( the code is below ) : set a=1 set b=a echo %%b%% The expected result is : 1 As a is assigned to variable b and 1 is assigned to variable a . Also, there is another situation : set b=a set a1=100 set c=1 call set d=%a%c%% echo %d% I want the program to first turn %c% to 1 and then turn %a1% to 100 . The expected output is 100 . What is the simplest way to complete this task? set a=1 set b=a call echo %%%b%%% And this will work faster: @echo off set a=1 set b=a setlocal enableDelayedExpansion echo !%b%! endlocal And just in case you need to do this

How can I launch VI from within Java under commons-exec?

霸气de小男生 提交于 2019-11-29 14:38:26
I would like to be able to launch VI from within my Java program and wait for the user to quit VI before proceeding. Here's the code snippet that I have currently: ... String previewFileName="test.txt"; // the file to edit CommandLine cmdLine = new CommandLine("/usr/bin/vi"); cmdLine.addArgument(previewFileName); cmdLine.addArgument(">/dev/tty"); cmdLine.addArgument("</dev/tty"); Executor executor = new DefaultExecutor(); try { DefaultExecuteResultHandler resultHandler = new ResetProcessResultHandler(cmdLine); executor.execute(cmdLine, resultHandler); } catch (IOException e) { throw new Error(

How do I alias a command line command? (Mac)

坚强是说给别人听的谎言 提交于 2019-11-29 14:06:46
I'm on a mac, and I write quite a bit of python scripts. Every time I need to run them, I have to type ' python script_name.py '. Is there I way to make it so I only have to type like ' p script_name.py '? It would save some time :D I am assuming you are running your script from the command line right? If so, add the following line as the first line in your script: #!/usr/bin/python or alternatively #!/usr/bin/env python in case the python command is not located in /usr/bin , and then issue the following command once at the Unix/terminal prompt (it makes your script "executable"): chmod +x

Execute shell command in Tomcat

白昼怎懂夜的黑 提交于 2019-11-29 14:00:32
So I have the following problem: I have a web service running inside a Tomcat7 server on Linux. The web service however has to execute some commands (mostly file operations such as copy and mount). Copy I've replaced with java.nio, but I don't think that there is a replacement for mount . So I'm trying to execute shell commands out of my Tomcat Java process. Unfortunately it doesn't execute my commands . I've implemented the execution of shell commands in Java before. So my code should be correct: Process pr = Runtime.getRuntime().exec("mount -o loop -t iso9660 <myimage> <mymountpoint>"); pr

Reading output from command into Perl array

大城市里の小女人 提交于 2019-11-29 13:19:07
I want to get the output of a command into an array — like this: my @output = `$cmd`; but it seems that the output from the command does not go into the @output array. Any idea where it does go? This simple script works for me: #!/usr/bin/env perl use strict; use warnings; my $cmd = "ls"; my @output = `$cmd`; chomp @output; foreach my $line (@output) { print "<<$line>>\n"; } It produced the output (except for the triple dots): $ perl xx.pl <<args>> <<args.c>> <<args.dSYM>> <<atob.c>> <<bp.pl>> ... <<schwartz.pl>> <<timer.c>> <<timer.h>> <<utf8reader.c>> <<xx.pl>> $ The output of command is