0
votes
1answer
40 views

Special Parameter query - multiple used to obtain command name? [duplicate]

In a uni text provided us to cover bash scripting, the following variable assignment has got be stumped and I've yet to get an answer back from anyone, hence hopefully someone on here can help. ...
12
votes
0answers
355 views

Should I use $* or $@? [duplicate]

Which one of $* or $@ is better to use (in array syntax,command line parameters, etc.) to avoid any bugs/problems in code? Or it does not make any difference?
1
vote
1answer
162 views

Execute command supplied by function parameters

I'm trying to create a function method in a bash script that executes a command which is supplied to the method by the paramters. Meaning somethings like this: special_execute() { # Some code ...
2
votes
4answers
299 views

How to write a very simple wrapper that provides default parameters?

Given a program that requires some parameters, e.g. program -in file.in -out file.out, what would be the simple-most approach to write a bash script that could be called with or without any of these ...
1
vote
1answer
642 views

Passing Command Line Arguments to java From JPackage Script

I installed Rachota -- a time tracking program written in Java -- from the Fedora repo, and yum installed the rachota.jar file to /usr/share/java, but it also created a script at /usr/bin/rachota. ...
4
votes
1answer
366 views

Writing command synopsis in standard man format

I am writing a script and in the usage() function I want to specify the usage. My script uses either option1 or option2 or both. One of them is mandatory. Is there a standard way to write it up?
8
votes
1answer
14k views

How to check if there are no parameters provided to a command?

How do you check if $* is empty? In other words, how to check if there were no arguments provided to a command?
5
votes
3answers
4k views

Print shell arguments in reverse order

I am a bit stuck. My task is to print the arguments to my script in reverse order except the third and fourth. What I have is this code: #!/bin/bash i=$# for arg in "$@" do case $i in ...
12
votes
2answers
2k views

How to safely pass variables to root-enabled scripts?

This question is totally general and not only applicable to my situation, but... I have a small busybox appliance where I want a non-root user to be able to execute a particular script with root ...