Questions tagged [command-line-arguments]

Programming command line utilities that take parameters.

This tag should have questions relating to programming command-line utilities that take arguments.

A command line argument is a parameter passed to a command line program. For instance git status is the Git command line program with the parameter status. Git then acts accordingly to that parameter.

Command line arguments are used in command line programs from the Command Prompt on Windows, a shell on Unix and the Terminal program on Mac OS. These are not visual GUI programs, they are text based.

Learn more: Wikipedia Article Command Line

5018 questions
2
votes
1 answer

How can I call a function in a vbscript with 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…
BSanders
  • 295
  • 1
  • 6
  • 29
2
votes
2 answers

Pass an argument when calling a script in Rails console with load command

I know about accessing the command arguments using the ARGV array, but I've run into an issue. I have a script that I cannot run standalone and instead needs to be run in the rails console. Is there a way to pass arguments when calling a file as…
2
votes
1 answer

DOS Multiline batch command. How to add comments between arguments?

Id like to add comments like this: makecert -r ^ // This means SelfSigned -pe ^ // Private key is exportable -a sha512 ^ // The algoritm ... Is this possible? How?
Cristian E.
  • 3,116
  • 7
  • 31
  • 61
2
votes
2 answers

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

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 the given input an…
user1010101
  • 2,062
  • 7
  • 47
  • 76
2
votes
1 answer

Parsing a quadratic equation as a command line input

The goal is to create a program that takes a quadratic equation in quadratic form and solve it. Is there a different way to go about doing so other than StringTokenizer? Or is it possible to isolate just ^2 in StringTokenizer rather than ^ and 2…
2
votes
2 answers

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

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…
Chiyaan Suraj
  • 1,021
  • 2
  • 13
  • 27
2
votes
1 answer

Trying to read string "$$" from 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…
JayB
  • 397
  • 6
  • 21
2
votes
2 answers

Bash script: syntax error near unexpected token?

function nvis() { while true; do nvidia-smi sleep $1 done } I'm trying to use it like: nvis 2 and I get an error like: bash: syntax error near unexpected token `2' Sorry if this is obvious; I am kind of stumped.
capybaralet
  • 1,757
  • 3
  • 21
  • 31
2
votes
1 answer

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

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…
idanshmu
  • 5,061
  • 6
  • 46
  • 92
2
votes
1 answer

C programming with getopt(): giving command line flags criteria

I am beginning to teach myself C. I have run into a few bumps here and there but right now I am stumped by getOpt(). The main thing thats giving me trouble is when I try to make certain flags dependent on other flags. For example I want these to…
sudobangbang
  • 1,406
  • 10
  • 32
  • 55
2
votes
1 answer

Capture symbol "*" as an argument in a java program

I am trying to write a simple java calculator program capable of addition, multiplication, subtraction, and division. Within Eclipse, it works perfectly. But when I try to run it on Ubuntu Terminal, the symbol "*" is not recognized as an argument.…
hao
  • 635
  • 2
  • 8
  • 20
2
votes
1 answer

How to pass multiple arguments with pipe symbol into a bash-script's case statement

I have a script that organizes files in my downloads directory according to their filetype. function moveto { for filename in * do case "${filename##*.}" in $1 ) echo "!";; # echo statement for debugging esac done } I…
2
votes
1 answer

MS Access, How to determine the command line parameters that the current instance of application has started with?

I need VBA solution to get the command line parameters which has been fed to MS Access at the start up of the current instance of the application. e.g. if it has been started as Runtime and etc
user3310269
  • 23
  • 1
  • 1
  • 4
2
votes
1 answer

How to take command argument in Go?

I just start to learn Go, and I wrote a prime test program using the ProbablyPrime library. package main import ( "fmt" "math/big" "math" "os" "strconv" ) func prime_test(n int64, certainty int)(bool,float64){ var…
Nick
  • 8,451
  • 13
  • 57
  • 106
2
votes
1 answer

Xargs parallelism in Bash

So I have this function in BASH that I'm trying to understand - and it uses parallelism: function get_cache_files() { ## The maximum number of parallel processes. 16 since the cache ## naming scheme is hex based. local…
Mindaugas Bernatavičius
  • 3,757
  • 4
  • 31
  • 58