Questions tagged [command-line-arguments]

Programming command line utilities that take parameters.

0
votes
2answers
24 views

while loop not looping past 1

I am trying to use a while loop in Perl that takes one argument from command line, which is the number of hellos to print on the string. I wrote the following: # Basic settings to catch errors use ...
0
votes
2answers
22 views

Bash Shell Commands with options

I'm having issues with piping the translate command into the word count command using the shell for an assignment. Using Debian 9 Linux distro. I need to remove colons from the passwd file in the /...
0
votes
0answers
16 views

currency converter, i think the problem is found within the for loop or the method calling in main, need help fixing my code

Write a program CurrencyConverter.java (in a package named a02) that takes currency amounts in Euros (EUR), US Dollars (USD) and Japanese Yen (JPY) as command line parameters and converts them to ...
1
vote
1answer
53 views

How to check number of command line arguments + exception handling

How do I go about checking the number of command line arguments entered and then printing an error if its less than 3. static void Main(string[] args) { string file1 = args[0]; ...
1
vote
2answers
57 views

Command Line arguments to Robot framework via python file

language: python - 3.7.3 Robot framework - 3.1.1 proficiency: Novice I want to pass arguments to python file variables from command prompt and then want to print the same from robot file by adding ...
2
votes
2answers
88 views

Escape sequences in command line arguments (Java)

According to How to use line break argument When you define a String as "Hello\nHello" in Java, it contains no '\' character. It is an escape sequence for the line break: "\n" is just one ...
5
votes
2answers
142 views
+100

Commands with multiple common options going into one argument using custom decorator

I would like to make a module that makes it very simple to build click commands that share a lot of options. Those options are distilled into a single object that is passed into the command. As an ...
8
votes
1answer
90 views

Is there a %*SUB-MAIN-OPTS pair for short option processing?

The multi sub MAIN() command line parsing in Perl6 is sweet! As far as I can tell from the Command Line Interface docs there is only one option supported in the dynamic hash %*SUB-MAIN-OPTS to ...
0
votes
2answers
26 views

How to pass enviornment variables to jar file?

I want to set run configuration option : Environment variable while running JAR and run it using java code. How to set environment option while running jar through java code?
3
votes
1answer
31 views

Using command line arguments to extract from txt file and run specific classes in C++

I'm working on a project that needs to be run with either of the following commands: ./project.exe -Stack < [filename] ./project.exe -Queue < [filename] I am wondering why there is a - in ...
0
votes
0answers
13 views

How can I pass command line arguments from main function to call my user defined functions

I want to execute functions by calling the function from my main function. Say example execute Python script: python wrapper.py -os Windows I have defined 2 functions and calling from my main ...
0
votes
0answers
19 views

How to pass arguments to Scala Swing Application?

PURPOSE: I have written a small Scala Swing Application that displays a Spark Data Frame object in a Scala Swing Table control. QUESTION: I have been trying to find information on how to ...
1
vote
1answer
57 views

How can I split a T-SQL Command

How can I split a T-SQL Command in SELECT FROM WHERE GROUP For example i need split this command Text To lcSQLCommand TextMerge NoShow Flags 1 Pretext 15 SELECT a.HabitacionID, a....
0
votes
0answers
22 views

Python's argv array does not contain passed '#' from shell [duplicate]

I am trying to read passed arguments and I come up against a strange problem. The code is simple and looks like this: import sys arguments = sys.argv for argument in arguments: print(argument) ...
0
votes
3answers
24 views

variable as python array key but without initialized or declared

About in a python code which i seen in this site https://amaral.northwestern.edu/blog/function-wrapper-and-python-decorator The code def my_add(m1, p1=0): output_dict = {} output_dict['r1'] = ...
0
votes
1answer
23 views

Get (String[] args) from Java main in android

I am using a libary in my android app that is designed for standard java. It therefore asks for the "String[] args" that are the arguments in a standard java main function. Is there a way to get those ...
0
votes
3answers
32 views

How to give an input-file as argument an read it in Python?

I am trying to give an input file as an argument in Python using argparse, but somehow, Im getting an error. Here is my code: from argparse import ArgumentParser def main(): args = arg_parser....
2
votes
1answer
52 views

How should I fill an array of ints from a file using command line args? The size of the file and the no. of elements may vary

I am really new to programming in C. I have an assignment where I have to fill an array of integers from a text file using command line arguments. The array should be able to take in all the numbers ...
0
votes
0answers
31 views

How to pass an argument to an already running program (C#, WPF) [duplicate]

I would like to find a solution on how to pass an argument to an already launched C# program (WPF). The program is extensive, but it is easy to understand - a simple application: One main WPF window ...
1
vote
3answers
30 views

Loop over an shell argument which contains a list of values and write these values to a file

I have a shell script in Linux, which needs as input one argument, which can contains a list of ip adresses. These list needs to be written line by line to a file. ./myTestScript.sh 192.168.100.2,192....
-1
votes
0answers
13 views

How to the command line arguments in python spyder [duplicate]

I am getting an error while running the command line arguments in the spyder kernel, firstly can we the cmd line arguments in the spyder kernel if not possible, help me out how can run in the spyder ...
1
vote
2answers
45 views

passing 1 2 23 32 4 returns 4 in max function in python, why?

My codes def validate(): if len(sys.argv) > 6: print("No more than 5 arguments please") exit() def printArgs(): print("\nthe arguments are:\n") for arg in sys.argv[1:]...
0
votes
0answers
27 views

iterating over sys.argv to detect if element is a digit [duplicate]

Basically I want to check each command line argument (sys.argv()) to determine if the elements is a digit or not. I'm thinking something like... count = 1 if sys.argv[count].isdigit(): num = ...
-3
votes
2answers
121 views

Is it possible to obtain the _raw_/_unprocessed_ command line?

The windows API provides GetCommandLine() which returns the cooked command line used to start a process. For instance, if a console application is started with the command: MyProg.exe > OutputHere ...
0
votes
0answers
26 views

CmdLineException: Option takes an operand

While parsing in the below code, for Integer values I see error. Rest of the String options are working good. Can someone point out if there is a different behavior needed for int Options? import ...
-1
votes
1answer
17 views

C++ input redirection causing error while file arguments work

When I specify an input file as a file argument, like so: ./asm ex1_in everything works as it should! However, when I specify an input file using redirection, like so: ./asm < ex1_in the ...
-2
votes
1answer
51 views

How to process more than 2 arguments in Bash? [duplicate]

So, I want to pass 2 arguments and want those arguments to be processed in combination and separately too. I have coded the switch case to process them separately but I am not sure how to do process ...
1
vote
0answers
22 views

R script reporting wrong command line arguments

Apparently, in R, one can get args with the commandArgs() function. Let's try. The file's name is wtf.r: #!/usr/bin/Rscript args = commandArgs() asdf = list() asdf$arg1 = args[2] # Starting from 2 ...
0
votes
1answer
26 views

Command-line argument overwritten by default value when using subparser

I have a program with sub commands, but they all have common arguments (e.g. they all require input and output directories) which I included in the parent parser to avoid redundancies. However, I want ...
0
votes
2answers
68 views

In Win10 Batch File's Arguments: Replacing UNC Path Names' prefixes with known mapped drive

I work in a shared drive on a server. Sometimes people use its mapped drive, Q:\Folder\Subfolder\Etc\ Other times people use its UNC Path, \\server.com\shared data\Folder\Subfolder\Etc\ I have a ...
0
votes
1answer
31 views

Passing a file as one string argument to a bash function

I have a Bash function that wraps a java command for convenience. The command accepts an argument which is actually JSON and can be somewhat large, so I prefer to store it in a multi-line file. Here ...
0
votes
0answers
9 views

Can't encrypt via command line using PGP

I am trying to encrypt a .csv file from the command line using PGP. I have a requirement for it to be a self-decrypting archive and for it to use a passphrase. The version that we are using for this ...
-1
votes
1answer
54 views

How to parse command-line arguments from a separate function

I am attemping to parse a command-line argument from one function process_command_line which I will then use in a main function. The second command-line argument enables the name of a file input to be ...
0
votes
0answers
41 views

Add a flag to a standard shell command

I accidentally found the key of Meta(Alt_left)+M to enable mouse support using nano. I'd like to invoke nano -m for mouse support each time. ~ command -V nano nano is hashed (/bin/nano)
1
vote
1answer
30 views

Use a bash argument unlimited times?

I have a Grep function below: #!/bin/bash echo What directory contains the text files with your data? read mydirectory cd $mydirectory echo What should we name your output? read $myoutput for file ...
0
votes
1answer
31 views

C: Program asking for user input even when input file is given as an argument

My program needs to take in a file input, and if one is not given, it needs to consider user input as its input. When I feed an input file into the program like so: ./sim < ex1_in everything ...
0
votes
1answer
45 views

How to pass command line argument to Xcode based on build configuration

I would like to add the -FIRDebugEnabled argument to enable the debug view on the Firebase console but only when it is a debug or staging build. I have tried adding CommandLine.arguments.append("-...
-1
votes
2answers
95 views

Find value of command line argument in batch file

I am passing a list of arguments while running a batch file and need the value of a particular argument -logdir to set some dir path in my batch file. How can I first check if the -logdir is passed as ...
1
vote
2answers
44 views

Define an option that has both a mandatory and optional argument

I am currently trying to come up with a way to build a command-line option that when provided can either take one required argument or a second optional argument (in addition to the required one). I ...
2
votes
2answers
61 views

Cannot use all arguments of $@ with sh -c

In a script, I have a sh -c command that involves $@ but it seems that only the first item of $@ is taken into account : $ set -- --no-resume-playback https://www.facebook.com/TBN/videos/...
0
votes
1answer
58 views

Redirecting “command not found” to a file

So I'm writing a code for a project I'm working on. It's about redirecting input output and error using file descriptors. But there is a problem in error redirection. If I were in command line I would ...
1
vote
0answers
38 views

Argparse unrecognized argument?

What I want: python main.py --num_epochs 200 What I get: usage: main.py [-h] [--data_type DATA_TYPE] main.py: error: unrecognized arguments: --num_epochs 200 Original Code: import argparse # ...
1
vote
0answers
23 views

is the behavior of sys.argv[0] the same on windows when running script only with a path >like_so.py?

on Windows it's possible to run a python script >like_so.py, with the help of the Python launcher for Windows and file associations. here's two line python script, like_so.py: import sys print(sys....
1
vote
1answer
57 views

Pipe delimiter in .bat file

I am trying to export a table from BigQuery to Google CLoud Storage (GCS) using bq command in a bat file. The command has a parameter to export as a Pipe delimited file. The command works from the CLI ...
-2
votes
2answers
66 views

How to implement options on an executable in c?

I'm working on a socket program. I need to get informations regarding the adress of a server from a document. I need to be able to change what document I get those informations from when I run the ...
1
vote
1answer
39 views

Parsing command-line arguments without ignoring backslash

I need to take the first element of ARGV and save it as my template for searching through files. This element contains a backslash / but when I save it in a variable, the backslash disappears: my $...
-1
votes
4answers
107 views

Checking for specific command line arguments in C++

I am building a CLI app that should do something similar to this: ./app Welcome to the app, Type -h or --help to learn more. ./app -h list of commands:... Here is the code i am trying to build: #...
3
votes
1answer
75 views

Why is space not allocated before assignment for pointer variables that store the main's arguments that are to be used in the program?

I am writing a C program that requires me to take command-line arguments and use them in the program. What I don't understand is, why in the code, string arguments are assigned to a char* variable, ...
2
votes
2answers
152 views

How do I pass variable command line arguments for a python script, that runs from a batch file?

I want to start my python script from a batch file. It requires four arguments, that are processed in the script through sys.argv[n]. These arguments are paths, that are varying from programme call ...
0
votes
2answers
26 views

Passing Process.StartInfo.Arguments in C# as a string that contains double-quotes (") within itself

I wish to run the mongoexport.exe process through my C# code, for which, let's say, the arguments go something as follows: --query "query_syntax" The whole of the above text shall be stored in a ...

http://mssss.yulina-kosm.ru