5,058 questions
160
votes
10
answers
231k
views
How to pass arguments in pytest by command line
I have a code and I need to pass the arguments like name from terminal.
Here is my code and how to pass the arguments. I am getting a "File not found" kind error that I don't understand.
I have tried ...
128
votes
7
answers
103k
views
How to load program reading stdin and taking parameters in gdb?
Question cribbed from here:
I have a program that takes input from
stdin and also takes some parameters
from command line. It looks like this:
cat input.txt > myprogram -path "/home/user/work&...
3
votes
1
answer
3k
views
Why does PowerShell split arguments at spaces when invoked by a batch script and how to fix it?
Very simple setup, please do try this at home.
test.ps1
$args
test.rb (replace with language of choice, if necessary)
p ARGV
test.bat
@echo off
ruby test.rb "foo bar moo"
powershell .\test....
2
votes
1
answer
100
views
Launching a python script in vscode with arguments I get FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\USERNAME\\FolderName'
I am trying to debug python code in vscode using a launch config that asks for command line arguments.
My script is located here:
C:\Users\USERNAME\FolderName - With Spaces\_MyHome\Documents\Dev\...
0
votes
1
answer
82
views
Can I construct my own env::Args instance in Rust for testing purposes? [duplicate]
I'm writing a Rust program where I do manual command-line argument parsing. I skip the first argument since that's the executable and I don't care about that, then check the second argument for what ...
2
votes
2
answers
719
views
Python: command-line arguments --foo and --no-foo
For parsing boolean command-line options using Python's built-in argparse package, I am aware of this question and its several answers: Parsing boolean values with argparse.
Several of the answers (...
12
votes
4
answers
671
views
How to correctly pass a filename with a single quote to ffmpeg's subtitles filter in Python?
I'm writing a Python script using subprocess to hardcode subtitles onto a video. My code builds a complex filter graph for ffmpeg's -vf argument, which includes burning in multiple layers of styled ...
2
votes
2
answers
3k
views
Parsing command line args and executing a function in scala
I am trying to parse commandline arguments and execute a function that takes the parameters upon successful extraction of the parameters. I have an object called CurrencyExchangeRunner where the main ...
2
votes
1
answer
633
views
dotnet ef scaffold Unrecognized option '-t firstTable -t secondTable' - pass arguments stored in a string
I have a .ps1 file that I run from PowerShell, the code is as follows:
$strTables = ""
$tables | ForEach-Object{
$strTables += "-t $_ "
}
# $strTables = -t ...
2
votes
2
answers
1k
views
Take multiple arguments in batch file
I have a batch file test.bat
I understand we can give it multiple arguments and take those values using %1, %2, and so on. But I do not know how many arguments will be given. I thought of constructing ...
20
votes
4
answers
39k
views
Running apt-get for another partition/directory?
I have booted my system from a live Ubuntu CD, and I need to fix some package problems. I have mounted my hard drive, and now I want to run apt-get as if I booted normally. ie change the working ...
724
votes
11
answers
1.4m
views
What does int argc, char *argv[] mean?
In many C++ IDE's and compilers, when it generates the main function for you, it looks like this:
int main(int argc, char *argv[])
When I code C++ without an IDE, just with a command line compiler, I ...
5
votes
3
answers
6k
views
Firefox Private Tabs from Command Line [closed]
I am trying to make a batch file that would launch Firefox.
I need to open one private Firefox window with two tabs in it. I tried various combinations of -new-tab and -private-window, but I can't ...
1
vote
2
answers
137
views
System.CommandLine root command option handler fallback
I want to add a Option<bool> to the root command but still show the default output when the option is not provided.
RootCommand rootCommand = new RootCommand("My root command");
...
0
votes
1
answer
12k
views
The '<' operator is reserved for future use (PowerShell script from command line)
I am trying to run the powershell script from the command line along with the arguments but it is always failing with the below error. Can anyone help?
cmd /c "C:\Windows\System32\WindowsPowerShell\...
5
votes
2
answers
968
views
How do I do the bash equivalent of $PROGPATH/program in Powershell?
In GNU/Linux I would do:
PROGPATH=/long/and/complicated/path/to/some/bin
$PROGPATH/program args...
but in Powershell if I try this:
$PROGPATH=\long\and\complicated\path\to\some\bin
$PROGPATH\program ...
-1
votes
1
answer
270
views
Does any of the command line parsing libraries for C++ allow options with N arguments [closed]
I am porting a python script to C++ and have not found a way to express an argument such as:
--metadata KEY VALUE
In the C++ argument parsing libraries I've seen:
boost::program_options
TCLAP
Gflags
...
0
votes
3
answers
2k
views
Parsing arguments in Java
I'm trying to write a Java wrapper which will internally call a shell script passing the required arguments to the script. My class would be called as follows:
MyClass --arg1 value1 --arg2 value2 --...
6
votes
1
answer
127
views
Optimize without sacrificing usual workflow: arguments, POD etc
https://martimm.github.io/gnome-gtk3/content-docs/tutorial/Application/sceleton.html , abbreviated:
In Raku, it is important that the main program is kept small. This is because all code, program and ...
-1
votes
1
answer
90
views
What would be a suitable way to receive run-time arguments and combine them into an iterable object? [closed]
I'm struggling to get runtime arguments and combine them into a list. I'd like for run-time arguments to be like the following python main.py --all or python main.py --endpoint1 --endpoint2. I only ...
3
votes
4
answers
2k
views
Java RegEx for parsing the quoted arguments
Need a Java regex pattern for the following scenario:
Case 1:
Input string:
"a"
Matches:
a
Case 2:
Input string:
"a b"
Matches:
a b
Case 3:
Input string:
"aA Bb" cCc 123 4 5 6 7xy "\"z9"...
8
votes
2
answers
4k
views
How do you tell if an option was specified when using System.CommandLine?
With a root command:
new RootCommand
{
new Option<string>("--myoption")
};
how do you tell the difference between
./myapp
and
./myapp --myoption ""
?
I initially ...
1
vote
0
answers
847
views
How to pass Task Scheduler correlation id to C# arguments program
I have a C# console application, which is triggered on Windows Task Scheduler periodically, but I need to get the "Correlation ID" of process started and pass to my app by argument, like the ...
1
vote
4
answers
513
views
Extract positional path argument from list of arguments to "ls" in Bash
I am trying to parse a list of command-line arguments (contained in the special "$@" Bash variable) that shall be passed on to the Linux ls binary.
The arguments may optionally contain keyword ...
-1
votes
2
answers
74
views
Does ArgumentParser support different arguments per file, ffmpeg style?
I want my application to work on several files and have a different set of options for each input file:
python my.py -a file_a -b file_b --do-stuff=x file_c
ffmpeg uses this idea for its command line ...
0
votes
1
answer
110
views
What is wrong with my reading of command line arguments? [duplicate]
I am writing a program for working with functions and graphs, but that is beside the point. In my int main() I just look at the command line arguments, and then match them up to the expected result.
...
1
vote
3
answers
465
views
How to parse keys in bash from command line?
I'm trying to make a command line tool out of a bash script. It is very simple:
grep ">" in_file >> out_file.
So I want to copy all lines containing '>' from the first file to the second.
...
0
votes
2
answers
1k
views
Shell - how to access arguments passed as flags
I want a shell script that can take advantage of a few optional flags in this style:
script.sh --foo "foo message" --bar "bar message"
script.sh --foo "foo message"
...
1
vote
1
answer
100
views
Script with parameters to be fed to the commands in the script
I want to make a bash script which invokes some simple commands in the following way
./myscript magicword
would invoke
#!/bin/bash
cat * | grep "$@"
However I want to add one more level of ...
0
votes
1
answer
74
views
Variable concatenation not working in command file [duplicate]
I searched and couldn't find anything on concatenating strings and numbers in a windows command script. I am trying to get create a log file with the date and time in the name and alls I get is the ...
1
vote
1
answer
50
views
accessing bash arguments and commands
There is plenty of info out ther about accessing -a type arguments
But I want to create a script with usage like so, Actually I have already writin the help text
usage: pubkeys command options
This ...
0
votes
1
answer
527
views
Bash scripting using getopts not accepting multiple arguments
I'm trying to build a script in bash and building a getopts loop. I have two options(x and h) that don't have any arguments and the other two have it. But my while loop fails by taking only one option ...
1
vote
1
answer
183
views
Passing inputs to Commands in Command line for user prompt
Suppose I execute a command which prompts the user for input. Is there a way by which I can pass the input in the command itself, rather than taking the input from the user. Like for example, in ...
0
votes
1
answer
239
views
How do I pass a path to this Shell script?
This tiny Shell script called prepareFastaRef.command is supposed to receive a file name I am giving as an argument, generate the path based on it, then run a command on that file. It looks like:
#!/...
0
votes
1
answer
57
views
How can I iterate through options provided to a shell script through a command line?
I have a script that can be provided with [the potential] to have an unknown quantity of known arguments
That is, I know ALL the arguments that can be provided, but as they are all optional, they may ...
0
votes
1
answer
78
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)
0
votes
1
answer
90
views
Reading command line args from shell script [duplicate]
I am trying to read a piece of text as a command line arg and print it out. This is my shell script (script.sh):
#!/bin/sh
input=${1}
echo ${input}
This is how I am calling my script: ./script.sh Af)...
0
votes
0
answers
43
views
How to open additional files in existing OpenSCAD instance
In case it matters, I'm running 2025.06.25 of OpenSCAD. If I have an instance of OpenSCAD running I can open additional source files such as libraries in the same instance using the menu system. Such ...
-1
votes
2
answers
2k
views
Windows cmdkey parameters: targetname
The windows cmdkey command can be used to add credentials for accessing remote resources.
cmdkey
For the most part, it is clearly documented. One part that is not is the targetname parameter. ...
1
vote
1
answer
2k
views
Different behaviour with echo vs printf command line arguments in zsh
I have a simple program to print the command line arguments in zsh. However, I see different behaviour with printf vs echo. Can anyone explain?
#!/bin/zsh
echo "$# @ : "$@" "
...
264
votes
6
answers
239k
views
What is docker run -it flag?
I was doing some complex stuff with Docker, but as turn out I don't know what -it flag means.
Recently I've come across on some example of docker run command which has confused me a little:
docker run ...
26
votes
6
answers
29k
views
Is it possible to pass in command line variables to a bitbake build?
I have an OpenEmbedded environment using bitbake to do some builds. I wanted to get something "interactive" going on where bitbake would pause and ask for input then continue with the build but I've ...
5
votes
1
answer
215
views
How does Rust's Command handle cmd.exe and batch script arguments?
A while ago there was a security advisory published for Rust that the standard library's Command API was not sufficiently handling arguments passed to cmd.exe and .bat files such that malicious ...
0
votes
2
answers
2k
views
How to handle command line arguments in TCL
I am writing a TCL scripts which expects command line arguments. Say the name of my script is myTcl.tcl , and in this case , invoking script with the command line arguments will look something like :
....
10
votes
2
answers
17k
views
Mac OS X: Getting detailed process information (specifically its launch arguments) for arbitrary running applications using its PID
I am trying to detect when particular applications are launched.
Currently I am using NSWorkspace, registering for the "did launch application" notification. I also use the runningApplications method ...
908
votes
33
answers
1.0m
views
Argument list too long error for rm, cp, mv commands
I have several hundred PDFs under a directory in UNIX. The names of the PDFs are really long (approx. 60 chars).
When I try to delete all PDFs together using the following command:
rm -f *.pdf
I get ...
560
votes
33
answers
631k
views
Using getopts to process long and short command line options
I would like to have the long and short forms of command line options invoked using my shell script.
I know that getopts can be used, like in Perl, but I have not been able to implement the same using ...
143
votes
9
answers
383k
views
How can I parse command-line arguments in a Perl program?
I'm working on a Perl script. How can I parse command line parameters given to it?
Example:
script.pl "string1" "string2"
0
votes
1
answer
107
views
How to implement logic to process dynamic command-line arguments with Spring Shell?
I'm working on a Spring Shell-based application where I need to process dynamic command-line arguments. I have implemented logic for a specific format, but I’m encountering issues when the order and ...
1
vote
1
answer
86
views
gcc OR clang command line invocation argument / parameter order precidence Last or First wins?
Search engines and reading the manuals are failing me. I'm not sure if there's a way to have E.G. gcc or clang output the final 'configuration' result of parsed command line arguments to check myself ...