All Questions
11
questions
0
votes
2
answers
126
views
Bash : Give builded array to function as a list of argument?
I have this issue with borgbackup, but because the reaction is the same, I will use rsync in my example.
I want to build an array of arguments by adding a prefix to each, and then give that array to ...
5
votes
2
answers
2k
views
How to re-write this function to avoid argument injection
I have a function in my .bashrc file that allows me to run a script on a remote server with arguments via ssh.
Currently, the function contains:
function runMyScript {
if [ $1 = "s3" ]
then
...
2
votes
1
answer
4k
views
Passing a git command as an argument
I'm trying to automate some tedious parts of a student job I'm working on.
Basically, the goal is to clone a bunch of git repositories (which I already have working), then run the same git checkout ...
3
votes
2
answers
10k
views
Passing paths with spaces as arguments
I am having difficulty in passing some string variables having spaces in them as arguments to a program.
For debugging and showing the arguments being passed, I created a demo Python script -:
#####...
21
votes
3
answers
16k
views
How does 'find -exec' pass file names with spaces?
If I have a directory containing some files whose names have spaces, e.g.
$ ls -1 dir1
file 1
file 2
file 3
I can successfully copy all of them to another directory like this:
$ find dir1 -mindepth ...
18
votes
2
answers
12k
views
Bash string concatenation used to build parameter list
Given this piece of bash:
PARMS='-rvu'
PARMS+=" --delete --exclude='.git'"
echo $PARMS
rsync ${PARMS} . ${TARGET}
The echo shows the PARMS string as expected, no error is displayed, but rsync ...
52
votes
3
answers
75k
views
Add arguments to 'bash -c'
Let's say that I want to run a command through Bash like this:
/bin/bash -c "ls -l"
According to Bash man page, I could also run it like this:
# don't process arguments after this one
...
1
vote
1
answer
483
views
How to enclose a quoted variable in quotes
I want to call: ./mjpg_streamer -i "./input_uvc.so -r 320x240" -o "./output_http.so -w ./www" from a C program, running system().
The problem is that I have to enclose shell command in quotes, which ...
1
vote
1
answer
2k
views
Bash Script : Passing a variable to a bash script that contains quotes, single quotes. etc [closed]
lets assume this is the string:
'a',"b"
it contains both single and double quotes.
how would you pass this to a bash script as a single string ?
this is the bash script:
#!/bin/bash
echo $1
...
14
votes
4
answers
19k
views
How to prevent command injection through command options?
I have an wrapper application where I need to let the user specify custom options to pass to a simulator. However, I want to make sure the user doesn't inject other commands through the user options. ...
148
votes
11
answers
55k
views
What is the difference between $* and $@?
Consider the following code:
foo () {
echo $*
}
bar () {
echo $@
}
foo 1 2 3 4
bar 1 2 3 4
It outputs:
1 2 3 4
1 2 3 4
I am using Ksh88, but I am interested in other common ...