FAQ Database Discussion Community


Setting an environment variable on same line as program execution is different than setting it separately? - shell variables vs. environment variables

bash,shell,environment-variables,command-line-arguments
What is the difference between: prompt$ TSAN_OPTIONS="suppressions=/somewhere/file" ./myprogram and prompt$ TSAN_OPTIONS="suppressions=/somewhere/file" prompt$ ./myprogram The thread-sanitizer library gives the first case as how to get their library (used within myprogram) to read the file given in options. I read it, and assumed it was supposed to be two separate lines, so...

How to read a text file in to a scanner using command line in Java

java,command-line,command-line-arguments
I have a small snippet of code that will ask user to type input such as 5 12 59 58 28 58 The first number will indicate the size of the array i need to create and the rest of the numbers will be stored in that array. So with...

Cannot access private member declared in class 'CCustomCommandLineInfo'

c++,mfc,command-line-arguments
I am trying to add a command-line interface to an existing MFC application, and found a class online at this website. I have adapted it to my needs and when I try to build I get an error that reads "error C2248: 'CCustomCommandLineInfo::CCustomCommandLineInfo' : cannot access private member declared in...

Bash Script: options - case: range of multiple numbers

linux,bash,case,command-line-arguments,optional-arguments
I'm working on a script in Linux Bash, with different kinds of options to use. Basically, the program is going to ping to the given ip-address. Now, I want to enable the user to write a range of ip-adresses in the terminal, which the program then will ping. Fe: bash...

How do I show processes for a specific uid or username using command line in python?

python,process,command-line-arguments
for opt, arg in opts: if opt in ('-u'): arg = numuid ps = subprocess.Popen('ps -u ', shell=True, stdout=subprocess.PIPE) print ps.stdout.read() this is what i have so far, numuid is supposed to go after ps -u and is the uid. but what do i do to have it read in...

passing arguments to a cURL shell script file

python,shell,curl,command-line-arguments
I do not have much experience with shell or python scripts so I am looking for some help on how I can accomplish this. Goal: Pass arguments to a shell or python script file that will be used to perform either a cURL Post request or a python post request....

Writing text into and retrieving text from the text file using command line auguments

c++,text,command-line,command,command-line-arguments
Hello I want to write the output of my C++ Program in a text file using Command Line Argument then afterward retrieve it from the file . can you help me please I cannot get a satisfying code help.

Running executable files using Haskell

shell,haskell,command-line-arguments,executable
Say there's a C++ code that I've compiled into an executable using: g++ test.cpp -o testcpp I can run this using Terminal (I'm using OS X), and provide an input file for processing inside the C++ program, like: ./testcpp < input.txt I was wondering if doing this is possible, from...

trouble with str.isnumeric()

python,python-3.x,command-line-arguments,isnumeric
Im trying to test whether a command line argument is a number or not by using the isnumeric string method. It is to my understanding that it returns True if all characters are numeric and false if otherwise however when running it I seem to be getting True regardless of...

Create parser with subcommands in argparse, customize positional argument(s)

python,command-line-arguments,argparse
I'm very new to this module so please bear with me. I have the following code: reader.py import argparse parent_parser = argparse.ArgumentParser(description="Read text files.") parent_parser.add_argument('filename', help='TXT file', type=file, nargs='+') parent_parser.add_argument('--verbose', '-v', action='store_true', help="Verbosity on") child_parser = parent_parser.add_subparsers(title="subcommand", help="Subcommand help") new_file_command = child_parser.add_parser('new', help="New text file") edit_file_command =...

Give command line argument (c++)

c++,command-line-arguments
This is a Robot Car program, which has gangsters and cops who catch them. How can I give the number of cops with command line argument? Here is the code (myshmclient.cpp): #include <myshmclient.hpp> char data[524288]; std::vector<justine::sampleclient::MyShmClient::Gangster>justine::sampleclient::MyShmClient::gangsters ( boost::asio::ip::tcp::socket & socket, int id, osmium::unsigned_object_id_type cop ) { boost::system::error_code err; size_t length...

Use numeric value of input argument in Bash script [duplicate]

linux,bash,command-line-arguments
This question already has an answer here: Brace expansion with variable? 5 answers I would like to use the numeric value of the input argument that I pass to a bash script like this: ./script_pb3.sh out.txt 3 Here I would like to take the second argument that I pass...

How to read values from command line in bash script as given?

bash,shell,command-line-arguments
I want to pass arguments to a script in the form ./myscript.sh -r [1,4] -p [10,20,30] where in myscript.sh if I do: echo [email protected] But I'm getting the output as -r 1 4 -p 1 2 3 How do I get output in the form of -r [1,4] -p [10,20,30]...

Passing multiple arguments as comman line args

arrays,vb.net,command-line-arguments
I am calling one .NET app from another using Process.Start and passing in a bunch of strings as command line arguments: startInfo.Arguments = String.Join(""" """, MyArray) Dim p As Process = Process.Start(startInfo) My intent is to pass in something like: "first value" "second value" "third value" and retrieve from within...

Using Net.exe, how do you add a user group with a 'Description' field as shown in Windows Computer Management?

windows,command-line-arguments
I knew how to add a user group using net.exe: net localgroup/group madeupgroupname /add This simple question was eluding me, perhaps because it is obvious: "How do you do this, and change the description that appears when you view the groups in computer management?" I saw the code: net localgroup/group...

Command line arguments and read file/print text in C

c,process,command-line-arguments
I am trying to work with command line arguments and parsing a text file in C. Basically I want to be able to put in two numbers, like, 1 and 4 and have it read a column of a text file then print it to stdout. I want to be...

Golang command arguments empty causing error

go,command-line-arguments
I'm writing a go program and I need to use command arguments. However if I don't pass arguments when I run the executable or go run gosite.go the code it does the following runtime error. panic: runtime error: index out of range goroutine 1 [running]: runtime.panic(0x80c8540, 0x816d4b7) /usr/lib/go/src/pkg/runtime/panic.c:266 +0xac main.main()...

How to make “if” condition change automatically depending on Command Line Argument in Java?

java,if-statement,command-line-arguments
In my code, if condition should change depending on command line argument. For example in the code below: int a = Integer.parseInt(args[0]); for (int i = 0; i < 100000; i++) { if (a == 2) if ((i % 25 == 0) || ((i+1) % 25 == 0) // do...

Expanding variables in a Windows batch file

batch-file,command-line-arguments,batch-processing,command-prompt
I run the following command in a Windows batch file: start "" "C:\PDF Viewer\PDFXCview.exe" /A "page=1&zoom=33.3" "G:\my pdfs\file 1.pdf" /A "page=4&zoom=55.5" "G:\my pdfs\file 2.pdf" The works perfectly fine and opens both PDF files using their respective parameters. However, to make the process cleaner, I would like to start using variables...

C# Regex command-line argument parsing with single hyphen word wrapping inside argument names

c#,regex,parsing,command-line-arguments
I am developing an opensource/libre command-line parser for .NET which will be restrictive but clear. It seemed to be an easy task at first but for 2 days being trapped with regex problems, not so fun. :( I've been reading hours of tutorials about word matching and grouping but it...

How to run another file using command prompt and continue with the rest of steps without waiting for the file to be closed

batch-file,command-line,command,command-line-arguments,command-prompt
I came across a strange scenario where it works intermittently. Requirement: Need to back date the system date before running a file and once the file is ran the system date should be reverted to the current date. I have written a code which works for one of the file...

How to correctly quote a command with parameters in a Windows batch file

batch-file,command-line-arguments,batch-processing,command-prompt
I am attempting to open multiple PDF files in multiple tabs in multiple windows using PDF X-Change Viewer, which has command line options. All PDF files listed in the same line open within the same window. To allow the script to proceed without waiting for the windows created on each...

Updating Ubuntu 11.04 to 12.04 preferrably through command line

linux,command-line,installation,command-line-arguments,updates
I am attempting to update my Ubuntu Natty Narwhal (11.04) to Precise Pangolin (12.04). When I checked the Update Manager, I was told I couldn't do that. I had to get to 11.10 first, if I want it safely. Sounds like a plan. And so I've ran through the Update...

Why does my program not check the number of arguments correctly?

c,command-line-arguments,binary-search-tree,stderr
Okay so I am writing code for a binary search tree that must read in strings from an input file: "input.txt" and I am trying to feed my program command line arguments. My program is supposed to take two command line args, the name of the program then the name...

how to execute a command using array containing strings with spaces linux

arrays,linux,bash,command-line-arguments
I have been stuck on an issue for a couple of hours now regarding bash shell arrays. I am using an array of strings created from an inputFile using IFS=$'\n' as the separator. Each index of the array may contain multiple words separated by spaces. Each string represents a combination...

perl App::Cmd call subcommand from script

perl,command-line-arguments
I am trying to call a command line application implemented using App::Cmd from another script (without a system call). My application is taken from the tutorial for the package, having a a script yourapp: #!/usr/bin/perl use YourApp; an application class YourApp.pm: package YourApp; use App::Cmd::Setup -app; 1; and a command...

How to embed commandline arguments in a execution command?

python,c++,command-line-arguments
I need to pass the commandline arguments of my C++ code as the commandline arguments of my python script. My code looks like: int main(int argc,char * argv[]) { FILE *in; char buff[512]; cout<<argv[1]; string str = "python comparescript.py "+argv[1]+" "+argv[2]+" "+argv[3]; if(!(in = popen(str, "r"))){ cout<<"Image Comparison made successful";...

How can I append the values from an input file to the command line options using argparse?

python,command-line-arguments,argparse
Say I have a yaml input file (input.txt) that contains the following: names: [Bob, Jill] ages: [22, 31] county: somewhere my code to parse this: import yaml import argparse parser = argparse.ArgumentParser() parser.add_argument('--name', default=[], dest='names', action='append') parser.add_argument('--age', default=[], dest='ages', action='append') parser.add_argument('--county', dest='county') parser.add_argument( '--config-file', dest='config_file', type=argparse.FileType(mode='r')) args = parser.parse_args() print...

Calling a Powershell script with the “-command” parameter instead of “-file”

powershell,command-line,command-line-arguments
What is the difference between calling a powershell script like this: powershell.exe -file "myfile.ps1" and like this (which also works): powershell.exe -command "myfile.ps1" thanks, robert...

When reading command line arguments in Windows script, is there a way to escape the comma character?

batch-file,command-line,scripting,cmd,command-line-arguments
I am trying to read multiple input parameters from the command-line. The last one is expected to be a comma-separated list, but the script is only able to read the first word before the comma. That is, when I call the script: test.cmd a b c d,e,f %4 comes as...

CMake: Adding command line arugments to project

cmake,command-line-arguments
My question is somewhat similar to this SO but not the same. I created a HelloWorld program with the following: add_executable( HelloWorld ${SRC} ) When I generate a project file (for example a Visual Studio .sln file, or a XCode .xcodeproj file). I want to hit the run button and...

Linux how to pass date command's output as input for a python program as command line argument

python,linux,pipe,command-line-arguments
I am quite a newbie to Linux. I have a very simple Python script that accepts command line arguments and prints them. Now I just want to pass the date command's output as input to this Python script and print it. The Python script looks like this. import sys print...

Segfault for invalid long option

c,segmentation-fault,command-line-arguments,getopt,getopt-long
I have the following code: struct option longopts[] = { {"version", no_argument, 0, 'v'} }; if (argc > 1) { int c; int longindex; while ((c = getopt_long (argc, argv, "v", longopts, &longindex)) != -1) { switch (c) { case 'v': puts (VERSION_INFO); exit (0); case '?': exit (1); }...

Python Command Line Arguments: Calling a function

python,command-line,command-line-arguments,argparse,optparse
So I'm stuck on a project I'm working on that involves the command line in python. So basically, here's what I'm trying to accomplish: I have a set of functions in a class, say, def do_option1(self, param1, param2) : #some python code here def do_option2(self, param1): #some python code here...

Parsing command-line entries in C: implementing a shell

c,shell,command-line,command-line-arguments,command-line-parsing
I'm implementing a shell in C, and I ran into some problems parsing command-line entries. I want my parser method to separate command-line entries that are delimited by the whitespace character, and return the result as a double char pointer. ie, say I have "ls -l >ls.txt", my parser should...

Trying to read string “$$” from command line arguments

c++,string,char,command-line-arguments
I'm trying to get a string from the command line arguments, one of the arguments I'm trying to use is "$$". The argument resides in argv[2]. My program reads "$" fine (argv[2] = "$"), but when "$$" is used, argv[2] = "29628".... What's going on here? ...

Python Args not working correctly

python,command-line-arguments
I have this program that is supposed to allow the user to input a start/end arg as well as a file arg and then the program will open a txt file and read line line s starting and ending at the args. but if i type in 2 as the...

Command Line Arguments for two .txt files [duplicate]

c#,command-line-arguments
This question already has an answer here: What is “string[] args” in Main class for? 8 answers I have the following program which simply reads two matrices from .txt files into 2D arrays. And I run it from Developer Command Prompt for VS2012 like first picture using System; using...

How does ARGV get processed in Perl if I pass two sets of values to it?

perl,shell,command-line-arguments
If I use ./test.pl file1 file2, I know the values are stored in @ARGV as first and second value, such that $ARGV[0] equals file 1 and so on. However if I pass the command as ./test.pl ./folder1/* ./folder2/* where each folder has 1000 numbered files, how is @ARGV numbered? I...

Setting a flag using a command-line argument with Argparse4j

java,command-line-arguments,argparse4j
I am using argparse4j to parse command line arguments. I want to add an argument that when present, sets a boolean to true, otherwise it defaults to false. I don't want to include the true or false in the argument, just the identifier, so it would look something like this...

How to run pytest.main(“-v test_script2.py”) when test_script2.py needs some command line arguments in order for the test functions to run?

python,command-line-arguments,py.test
I have two scripts. One script parses all the arguments and decides the control flow of the script. Another script has all the test functions defined and I wanted to use pytest module to invoke the 'test_script2.py' and run all the tests. But there are some arguments that I need...

How to add command line argument to a web application(Spring MVC)

web-applications,wsdl,cxf,command-line-arguments
I'm working on a web project that uses Apache CXF and web services, which i use to hit a request to server and get the response back. The server(Actually the service provider) had given me some username and password. Now, when I run my request as a java application...

How to split an UTF-8 string by an escape sequence provided as command line argument in Python 3?

python,string,split,command-line-arguments,ansi-escape
I'm trying to seperate UTF-8 strings by a delimiter provided as command line argument in Python3. The TAB character "\t" should be a valid option. Unfortunately I didn't find any solution to interpret an escape sequence as such. I wrote a little test script called "test.py" 1 # coding: utf8...

How can I easily create a python argparse argument with an inverse?

python-3.x,command-line-arguments,argparse
Using argparse with Python 3, I'd like to create a complementary pair of arguments: --log-file=~/some-default-log-filename.txt --no-log-file As the example implies, by default the log file arguments would have a default value (a filename). You could change that by specifying a different string value to --log-file, or remove the log file...

Passing command line arguments to process when debugging with GDB/Eclipse

eclipse,debugging,process,gdb,command-line-arguments
I'm trying to debug process with GDB from Eclipse (CDT). I can start debugging, step on code and so on. So, basic setup seems to work. However, I don't understand how to pass command line arguments to process. Executable is not built with Eclipse, I use separate make files. Steps...

how to pass input and configurations files by using linux command

c++,linux,parameters,command-line-arguments
I have an executable file vs-vectorize for which I want to pass a file to analyze along side its configuration files. I am Very very new to linux so excuse my question. The file to analyze is in xml format: <doc id="E0211315"> <text> Gimme Dat For the Chris Brown song,...

How can I call a function in a vbscript with command line arguments?

vbscript,cmd,command-line-arguments
I have a script that executes remotely to see if a program is running. It works fine but I need it to check for several programs on several servers and I don't want to re-write it. I'm trying to see if I can call the function within the vbscript via...

Run python script with some of the argument that are optional

python,command-line-arguments,argparse,sys
I have gone through the sys documentation, however there is something that is still unclear to me. I have looked for some similar question on stackoverflow, but I haven't find anything useful (clearly any reference is appreciated!). I want to create a script - say foo.py - in which I...

Xcode won't pass arguments to C++ executable

c++,xcode,debugging,command-line-arguments
I'm attempting to debug a C++ project using Xcode. My program looks for input through stdin like so: string line; getline(cin, line); I have an input file called input.txt that I normally pass into the executable like so: ./verti < input.txt In order to accomplish the same thing while debugging...

How to Use Command Line Arguments to Dictate Flow of Program?

java,methods,command-line-arguments
I have scoured all of Google it seems and I cannot find anything regarding how to use command line arguments to tell the Java program which subsequent method to perform. I am trying to create a Java program with several different aspects of a student grading application. The main program...

Testing for pipe or console standard input with ARGF

ruby,input,command-line-arguments
I have written a script that I would like to take input either from a pipe or by providing a filename as an argument. ARGF makes it easy to deal with this flexibly, except in the incorrect usage cases where neither is provided, in which case STDIN is opened and...

Memory Management Command Line Arguments in C

c,command-line-arguments
I am writing a simple program that takes the command line arguments and stores them into a char **. I am trying to learn more about memory management but cannot get past this simple stumbling block. My program is supposed to copy the command line argumetns into a dynamicly allocated...

sys.argv is different depending on the method of invocation of script

python-2.7,command-line-arguments
I have a simple Python script that all it does is: import sys print sys.argv When I open cmd and type MyScript.py arg1 I get: ['C:\\MyScript.py'] But when type: python MyScript.py arg1 I get: ['C:\\MyScript.py', 'arg1'] I've looked around here but did not find my answer. I've uninstalled and re-installed...

Best way to access image files to improve performance

c#,vb.net,image,performance,command-line-arguments
I am using a graphicmagick.exe (command tool) to convert the file from one format to another format: In that, I used to pass input path and output path for conversion as aruguments. Now I am looping a directory using foreach and passing the input file one by one and converting...

xargs - does the program run in loop or get re-executed

linux,command-line,command-line-arguments,execution,xargs
I have a C++ program that is outputting text strings which are read as command line inputs to my Java program. My question is does the Java program continuously run with new inputs given or does the program terminate and then get executed again when new command line arguments are...

Passing command line argument from the terminal with apostrophe or quote

bash,command-line-arguments
I have seen questions about passing arguments with quotes to a shell script (e.g., this question). My situation is slightly different: I am passing an argument to my java program from the bash terminal. The number of possible arguments is finite (20, to be precise), and one of them is...

Reading lines from .txt into batch file and handing into command line as arguments?

python,batch-file,command-line-interface,command-line-arguments
I need to read each line of a .txt file, line by line, handing in each line as an argument to a process I'm running in the CMD line interface. In the command line it would look like: "process c:/script.js arguments". I originally did this using Python: with open("C:\path\to\document.txt", "r")...

Passing array of arguments to Quartz Scheduler

java,command-line-arguments,quartz-scheduler
I am trying to add a Quartz Scheduler to an existing Java class. The class uses String[] args as input from the main function. public static void main(String[] args) { //validate(args); summarizeData(args); } But then the Java class implements Job, and it has to use the execute method which only...

Command line arguments is causing Exception in “main” thread

java,arrays,command-line-arguments,bubble-sort
import java.util.*; public class bubblesort { public int input; public int c; public int d; public int swap; public int[] arr= new int[input]; Random rand = new Random(); Scanner in = new Scanner(System.in); public static void main(String[] args) { bubblesort b = new bubblesort(); Scanner in = new Scanner(System.in); System.out.println("Ascending(1),Descending(2),Random(3)");...

How to interate through command line arguments saved in a variable?

bash,iteration,command-line-arguments
At some point in my script I need to save value of all command line arguments in a variable (after some shifting), it looks like this: foo="[email protected]" Now I need to interate through the arguments from foo variable, but it seems to be quite hard to do it properly if...

Change argparse usage message argument order

python,python-3.x,command-line-arguments,argparse
I'm using argparse in python3. In my script, I have some subparsers, a positional argument and some optional arguments. I have an optional argument to pass in any number of file paths, and it's using nargs='*'. The usage message for my script displays like this: usage: myprog.py subparser1 [-h] [--dir...

Parsing exclusive groups in Python

python,command-line-arguments,argparse
I have 2 group which are exclusive, you can define either arguments from group1 or group2 but group2 have to be exclusive within it's arguments too. parser = argparse.ArgumentParser() group_exclusive = parser.add_mutually_exclusive_group() sub_exclusive_1 = group_exclusive.add_argument_group() sub_exclusive_1.add_argument("-a") sub_exclusive_1.add_argument("-b") sub_exclusive_1.add_argument("-c") sub_exclusive_1.add_argument("-d") sub_exclusive_2 = group_exclusive.add_mutually_exclusive_group() sub_exclusive_2.add_argument("-AA")...

segmentation fault and argv, argc

c,segmentation-fault,command-line-arguments
I made a code that prints out the input: int main(int argc, char *argv[]) { printf("%c", *argv[1]); return 0; } When I put something like ab, abcdef, ac, *cf, it works well, but when I put ** or $$ it returns 2, and when I put $a, $k, and so...

Python handling options and args

python,arguments,command-line-arguments,options,getopt
I have written a python code and I want to handle switches and arguments. So I want to tell script: If you see -u then there is no -d <name> in arguments print "sth": if sys.argv=='-u' and sys.argv!='-d': print "You must use the -d switch!" sys.exit() Seems this is wrong...

C++ Unexpected calculation in program

c++,function,arguments,command-line-arguments
When my program is ran with a command line argument like 60, the first calculation is wrong but the rest seem to be correct. I think I have a bug in the main() function but I cannot find it. On Linux 60 gives ~30000 steps and on Windows it shows...

Dealing with backslash as a command line argument in Python

python,string,command-line-arguments,backslash
I know about escaping backslashes in programming. However I'm passing in a command line argument into a Python program to parse. Whitespace is irrelevant, however via the command line, whitespace does matter. So I am trying to concatenate all argv[] arguments except the first element into a string to then...

C++ How to pass command line argument to read txt file

c++,command-line-arguments
What I've been trying to do is... 1) to read txt files by command line argument, 2) to use strings in the txt files as arguments for the main method (or whatever method you need to invoke). For example, there are two txt files, one of which is named character.txt...

Adjust exception message basing on missing information

python,python-2.7,command-line-arguments,python-2.x,command-line-parsing
Having such code: if __name__ == "__main__": parser.add_argument("--u_shape_dict", default="", action='store', help="required for ...") parser.add_argument("--v_shape_dict", default="", action='store', help="required for ...") u_shape_dict = args['u_shape_dict'] if not u_shape_dict: raise Exception('u_shape_dict is missing. Please provide it') v_shape_dict = args['v_shape_dict'] if not v_shape_dict: raise Exception('v_shape_dict is missing. Please provide it') I want to combine this...

Why are command line arguments passed as a String array in Java?

java,command-line-arguments,main
In Java, the command line arguments are passed into my program as a String array, like this: public static void main(String[] args ) { } Why does this use an array, and not a single String ? I think it would be more flexible / adaptable if the command line...

Why does Scala ignore exclamation points in command line arguments?

scala,command-line-arguments
If I write a Scala script (or App) that just prints out the command line arguments, I notice that it ignores all the '!' characters. For example, if my script looks like: println(args(0)) And I run it with: scala MyScript "Hello!" I get the output: Hello And if I run...

Does jar differentiate between program arguments and jvm arguments

java,jvm,command-line-arguments
I am trying to execute a jar file. It needs both program arguments and the jvm arguments. Do we need to do something different while passing the command line parameters in order for it to be able to differentiate them, or it will be handled automatically? Currently I am using...

NSIS - printing to prompt during command line uninstall

command-line-arguments,nsis,uninstaller
I've written an installer for windows using NSIS. If the program is run from a console i want to write some information to this console. My code looks like the one in this question... NSIS - printing to prompt during command line install System::Call 'kernel32::GetStdHandle(i -11)i.r0' System::Call 'kernel32::AttachConsole(i -1)i.r1' FileWrite...

Using “extends” correctly to display inheritance in a Commandline argument

java,inheritance,command-line-arguments
The user is supposed to input a name, a last name, and the age in that order into the commandline, and it displays into a JoptionPlane. It then displays again with a Dr. in front of the arguments with the age increased by 1. However I am having trouble with...

Python argparse a list input

python,command-line-arguments,argparse
The code below accepts command line arguments for mode such as -m fizz and -m fizz bazz. This, as expected, passes the arguments to the main function as ['fizz', 'bazz'] (for the second example above). It seems user-unfriendly to pass command line arguments with spaces, so I'd like argparse to...

Passing arguments to a method in Rake Task [duplicate]

ruby-on-rails,ruby,command-line-arguments,rake-task
This question already has an answer here: How do I pass command line arguments to a rake task? 15 answers I have a Rake task wherein I am taking two arguments from command line and i need to pass those arguments to the method inside the task. How do...

How to make a short and long version of a required argument using Python Argparse?

python,command-line-arguments,argparse
I want to specify a required argument called inputdir but I also would like to have a shorthand version of it called i. I don't see a concise solution to do this without making both optional arguments and then doing my own check. Is there a preferred practice for this...

Use $^I and supply arguments

perl,file,command-line,command-line-arguments
I am trying to perform some inplace editing. And I have a basic snippet that works for when I have hard coded substitute in place. I am trying to generalize the script by passing in variables now and it fails. my code use strict; use warnings; $^I = '.bak'; my...

How to merge this functionality with argparse? [closed]

python,python-2.7,command-line-arguments,argparse
I have this functionality: import codecs from sklearn.feature_extraction.text import TfidfVectorizer with codecs.open('/Users/user/Desktop/file.txt', encoding='utf-8') as f: spanish_stop_words = [line.strip() for line in f] print spanish_stop_words from sklearn.feature_extraction import text my_stop_words = text.ENGLISH_STOP_WORDS.union(spanish_stop_words) tfidf_vect= TfidfVectorizer(stop_words=set(my_stop_words)) I was been struggling with the argparse documentation in order to understad where I can call the...

Test if string represents “yyyy-mm-dd”

c++,command-line-arguments
I am working on a program that takes two command line arguments. Both arguments should be dates of the form yyyy-mm-dd. Since other folks will be using this program and it will be requesting from mysql, I want to make sure that the command line arguments are valid. My original...

Accessing option data

python,command-line-arguments,options
I am trying to add an option to a Python program like so: optionParse= argparse.ArgumentParser(description='Change Number of Locations') optionParse.add_argument('-n') The -n option will allow the user to specify a number that will be used in the program. They will input it like this: myProgram.py -n 12 How would I access...

bash getopts validate options

linux,bash,scripting,command-line-arguments,getopts
I have following code in bash script: # argument validation and usage help usage() { cat << EOF usage: $0 options File Integrity Monitoring Script: OPTIONS: -b input file for [backup] -r input file for [diff report] -l list backup files EOF } if [ $# -eq 0 ] then...

how do I know what n(positive integer) is when user types ./a.out -n?

c,command-line-arguments
How do I make an command line argument a variable? That is, for example, how do I know what n(positive integer) is when user types ./a.out -n? I know I can use strcmp(argv[1], "-1") strcmp(argv[1], "-100") but is there a simpler way to implement this?...

Multiple file input, with stdin // Argparse4j, Java

java,file,command-line-interface,command-line-arguments,stdin
I'm trying to use Argparse4j to build a command line utility. I need to create an option that accepts multiple input files, but also accepts stdin: subparser.addArgument("input") .nargs("*") .setDefault(Arrays.asList("-")) .type(Arguments.fileType().acceptSystemIn().verifyCanRead()); If I don't use Arrays.asList, then sometimes I get just a File object, instead of a List<File>. However, using nargs("*")...

Options not parse as Argument in Unix

bash,command-line-arguments,getopt,getopts
I has an existing script which works on $1 $2 $3, etc. I want to add an optional argument without disturbing the order. Do we have some ready made solution for: If a valid option (using getopts) is found, this index of argument should not be considered as argument....

How to have a.out file read text file through terminal by typing “a.out < textfilename.txt”

c++,command-line-arguments
I'm new to programming and I couldn't find an answer to my problem. This is the code I have to have my program open and read the text file I want while running it on the terminal: using namespace std; int main(int argc, string *argv[]) { string fileName; getline(cin, fileName);...

Command line option for PuTTY (Windows) to set action of mouse buttons to xterm?

windows,command-line-arguments,putty
As per the title, I'm looking for a command line option which will have the effect of clicking xterm under "Window > Selection > Control use of mouse" in the PuTTY configuration window. I can't see anything in the standard command line options in the PuTTY docs and I'm trying...

How to pass Ctrl+Enter command to Process when using C# StandardInput redirection

c#,process,cmd,command-line-arguments,pos-tagger
Im trying to make C# application that uses hunpos tagger. Runing hunpos-tag.exe requires three input arguments: model, inputFile, outputFile In cmd it would look something like this: hunpos-tag.exe model <inputFile >outputFile Although, hunpos-tag.exe can be run with just the model, at that point it'll wait for text input (from cmd)...

Maven install not respecting command line arguments

java,maven,command-line-arguments,pom.xml
I have a project which I am attempting to install with maven. The pom.xml has a few properties in it which are modified when the maven install command is run depending on whatever version of a library we are attempting to build with: <properties> <some-version>0</some-version> </properties> The zero here is...

Create index.php file in directory [closed]

c#,file,directory,command-line-arguments
I want to write a program to be added to the right-click menu and when I run the program from the right-click menu to create an index.php file in current directory! Exmaple: I go to C:\wamp\www Then I right-click somewhere and want to choose create index.php This should create a...

Iterative command line arguments in Python

python,command-line-arguments
I am working on Python 2.7.9 and using argparse module for command line arguments. I want to extend my code such that it should be able to take the command line arguments depending on the arguments already given by the user in the same command line. Lets say, the arguments...

Parameter checks in bash not testing correctly

linux,bash,command-line,command-line-arguments
I've been scratching my head about this for a while... I'm trying to get my code to react like: If no parameters, go to menu If more OR less than 4 parameters, call error and go to menu If exactly 4 parameters, write to file and exit I can't get...

What are some use cases of “$*” in bash?

bash,parameters,arguments,command-line-arguments
From the bash man page: "$*" is equivalent to "$1c$2c...", where c is the first character of the value of the IFS variable. "[email protected]" is equivalent to "$1" "$2" ... Any example where "[email protected]" cannot work in place of "$*"?...

Manage multiple following positional argument with argparse

python,command-line-arguments,argparse,args
I'm using this lib for parsing arguments in python : https://docs.python.org/2/library/argparse.html So far I have this: prog arg1 [-s arg2 [arg2 ...]] [-m arg3 [arg3 ...]] And I want this: prog arg1 -s arg2 [arg2 ...] -m arg3 [arg3 ...] Here is my python code: parser = argparse.ArgumentParser() parser.add_argument('path', type=str,...

bash interactive script pass input

bash,command-line-arguments
I'm running the following interactive Jar. java -jar script.jar argument-line-here \n Now I'm creating a bash script which runs the jar file. How do I pass the argument line and the conformation "\n" to this interactive script? these are input lines for the script. This question has some answers, expect...