Sponsored Content
Top Forums Shell Programming and Scripting Pass command as a function parameter Post 302509674 by Franklin52 on Thursday 31st of March 2011 12:02:25 PM
Old 03-31-2011
Use eval to execute the command:
Code:
function execlocal {
        echo "Running CMD:\"$*\""
        eval $*
        STATUS=$?
}

CMD='ls -l | grep pl > out 2>&1'
execlocal $CMD

This User Gave Thanks to Franklin52 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

pass parameter to function

HI all I have a code like ############################################## minyear() { curryear=$1 echo $curryear } ##Main Program ## minyear exit ####### when i execute "sh scriptname 2005" output should be like 2005 but the output is blank. I guess i need to pass parameter to... (3 Replies)
Discussion started by: vasuarjula
3 Replies

2. Shell Programming and Scripting

What is the maximum number of parameter we can pass to a shell script function?

what is the maximum number of parameter we can pass to a shell script function (8 Replies)
Discussion started by: alokjyotibal
8 Replies

3. Shell Programming and Scripting

How to pass a parameter with double quotes around it to a command

In a bash script, I need to pass a parameter that has space in-between using double quotes as follows: CMD="SomeExecutable" # Parameter that has a space in-between PARAM1="TIMO 2" CMD_IN="--name=\"$PARAM1\"" CMD_OUT=`$CMD $CMD_IN` expected/required command execution:... (4 Replies)
Discussion started by: Timo
4 Replies

4. Shell Programming and Scripting

How to pass parameter to User defined function in shell script?

Hello, Can anyone guide me tin passing parameters into user defined function of shell script (KSH). Here is my code, InsertRecord() { DB_TBL=$(sqlplus $USERID/$PASSWORD@$DATABASE << EOF set head off set feed off set serveroutput on INSERT INTO TBL1 ( OLD_VAL, NEW_VAL, ... (7 Replies)
Discussion started by: Poonamol
7 Replies

5. Shell Programming and Scripting

How to pass a function with a variable parameter into another variable?

Hello again :) Am currently trying to write a function which will delete a record from a file. The code currently looks as such: function deleteRecord() { clear read -p "Please enter the ID of the record you wish to remove: " strID ... (2 Replies)
Discussion started by: U_C_Dispatj
2 Replies

6. Shell Programming and Scripting

Passing command as a function parameter

Hi All, Just trying to implement the below shell script using AIX ksh shell. myfunc { eval "$*" } CMD='ls -la /etc/hosts | awk '{print $9"|"$5}'' myfunc $CMD Keeping getting "|}: not found" errors, any pointers would greatly be appreciated. Kind Regards Ed Please... (2 Replies)
Discussion started by: eo29
2 Replies

7. Shell Programming and Scripting

How to pass parameter to pipe command row-wise?

Hi, I have a list of parameter in a file. I want to pass them one by one to piped command and syntax is like <command> <parameter> <command continues> How to achieve that ? Thanks (1 Reply)
Discussion started by: ezee
1 Replies

8. Shell Programming and Scripting

How to pass position parameter into function.?

Hi Gurus, I have request which needs to pass position parameter to a function. I tried below simple code, it doesn't work. #!/bin/bash func_1(){ echo $1 } func_1 $ ./set_file abc $ do I need add some to get the position para first? thanks in advance. (3 Replies)
Discussion started by: ken6503
3 Replies

9. Shell Programming and Scripting

How to pass function parameter to do loop?

Hi All, I have created one function for KSH and was running well with one parameter input since I just had to use $1 to get the parameter. Now I want to do loop for each parameter(actually filenames) . I have try to use do loop, but $i does not resolve to parameter instead it resolves to 1,... (5 Replies)
Discussion started by: mysocks
5 Replies

10. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies
TH-CMD(1)							Triggerhappy daemon							 TH-CMD(1)

NAME
th-cmd -- triggerhappy commander SYNOPSIS
th-cmd --socket <socket> [--passfd] [--tag <foo>] [--clear|--enable|--disable|--mode <mode>|--quit|--udev|--add <devices...>|--remove <devices...>] DESCRIPTION
This program is used to issue commands to a running triggerhappy daemon. It utilizes an unix domain socket bound by the daemon. OPTIONS
--socket socket The socket file opened by the running triggerhappy daemon instance. --add <devices...> Instruct the running daemon to open the input devices specified on the command line --remove <devices...> Remove specified devices from the running daemon. --clear Remove all devices from the running daemon. --udev Deduce operation and device name from udev environment (for use in udev rules). --disable Disable the execution of triggers. --enable Re-enable the execution of triggers. --mode <newmode> Change the mode of the triggerhappy daemon to <newmode>. If no new mode is specified, the daemon switches to default mode. --quit Terminate the triggerhappy daemon. --passfd Instead of instructing the daemon to open the device, open the device and pass the file descriptor to the daemon. This allows the adding of new devices to a daemon having dropped its privileges, however the th-cmd process must have access to the device file. --grab Grab the device; the triggerhappy daemon will try to get exclusive access to the device, other applications will not receive the events emitted by it. --tag foo Label the added device with the tag <foo>; this can be used to limit the scope of event handlers to a subset of input devices. AUTHOR
Stefan Tomanek <stefan.tomanek+th@wertarbyte.de> 0.3.4 2011-05-10 TH-CMD(1)
All times are GMT -4. The time now is 08:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy