user294567
user294567

Reputation:

Aquireing the entire string sent to the shell for execution

I have a bash script that looks like this (called job_result.sh):

#!/bin/bash
$* && zenity --title "Job result" --info --text "SUCSESS: Job '$*'completed" && while pidof zenity > /dev/null; do /usr/bin/wmctrl -a "Job Result" && sleep 2; done

When i execute it with:

$ ./job_result.sh echo "arf" && sleep 10

I want the following to happen:

$ echo "arf" && sleep 10 && zenity --title "Job result" --info --text "SUCSESS: Job '$*'completed" && while pidof zenity > /dev/null; do /usr/bin/wmctrl -a "Job Result" && sleep 2; done

But it seems the following is happening:

$ echo "arf" && zenity --title "Job result" --info --text "SUCSESS: Job '$*'completed" && while pidof zenity > /dev/null; do /usr/bin/wmctrl -a "Job Result" && sleep 2; done

Question: How do i get hold of the entire shell argument? And not just the part until &&?

Upvotes: 0

Views: 116

Answers (1)

ghostdog74
ghostdog74

Reputation: 342363

try putting quotes

$ ./job_result.sh "echo 'arf' && sleep 10"

here's a guess of what you want, and can do

put your parameters in a variable in another file. then when you want to use it, source the file eg

$ cat my_shell_libraries
export var="echo 'arf' && sleep 10"
$ . my_shell_libraries
$ ./job_result.sh $var

Upvotes: 1

Related Questions