[wplug] scripting -- executing a variable

Poyner, Brandon bpoyner at ccac.edu
Mon Feb 16 14:51:42 EST 2004


I'm not sure why $@ isn't working for you.  This works for me, two ways
of executing $@.

> cat test
#!/bin/bash

echo "Options: $@"
$@
exec $@
> ./test ps
Options: ps
  PID TTY          TIME CMD
 3111 pts/0    00:00:00 bash
 3801 pts/0    00:00:00 test
 3802 pts/0    00:00:00 ps
  PID TTY          TIME CMD
 3111 pts/0    00:00:00 bash
 3801 pts/0    00:00:00 ps

Brandon Poyner
Network Engineer II
CCAC - College Office
412-237-3086


-----Original Message-----
From: Ryan W. Frenz [mailto:rfrenz at andrew.cmu.edu] 
Sent: Monday, February 16, 2004 2:41 PM
To: wplug at wplug.org
Subject: [wplug] scripting -- executing a variable


I want to write a bash script that takes a command line argument and 
executes it, along with some other things.  What is an easy way to do 
this? 

# ! /bin/bash

set `getopt "$@"`

# run specified executable here
# $@; doesn't work

ps;
_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug



More information about the wplug mailing list