Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get list of arguments?

I'd like to find a Windows batch counterpart to Bash's $@ that holds a list of all arguments passed into a script.

Or I have to bother with shift?

like image 939
wheleph Avatar asked Dec 10 '08 19:12

wheleph


People also ask

What is list argument in Python?

You can send any data types of argument to a function (string, number, list, dictionary etc.), and it will be treated as the same data type inside the function.

How get arguments name in Python?

To extract the number and names of the arguments from a function or function[something] to return ("arg1", "arg2"), we use the inspect module. The given code is written as follows using inspect module to find the parameters inside the functions aMethod and foo.

How do you get arguments in R?

args() function in R Language is used to get the required arguments by a function. It takes function name as arguments and returns the arguments that are required by that function.

Can an argument be a list?

In Python, Arguments in a function may be of any data types like list, string, dictionary etc., Inside the function also it is treated as the same data type. If we give List as an argument to the function, it will consider the argument as List even if it is inside the function.


1 Answers

dancavallaro has it right, %* for all command line parameters (excluding the script name itself). You might also find these useful:

%0 - the command used to call the batch file (could be foo, ..\foo, c:\bats\foo.bat, etc.)
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9 (and SHIFT can be used for those after the 9th).

%~nx0 - the actual name of the batch file, regardless of calling method (some-batch.bat)
%~dp0 - drive and path to the script (d:\scripts)
%~dpnx0 - is the fully qualified path name of the script (d:\scripts\some-batch.bat)

More info examples at https://www.ss64.com/nt/syntax-args.html and https://www.robvanderwoude.com/parameters.html

like image 90
4 revs, 3 users 80% Avatar answered Sep 16 '22 11:09

4 revs, 3 users 80%