Sponsored Content
Top Forums Shell Programming and Scripting Specify an entire UNIX command as a command line argument Post 302770896 by nithinsen on Tuesday 19th of February 2013 01:13:01 AM
Old 02-19-2013
Try this code

Code:
#!/bin/bash

echo -n $1

read ANSWER

if [ "$ANSWER" = "y" -o "$ANSWER" = "Y" ]
then
      $2
else
      $3
fi

you can try executing it in ,
YN "Do you want to list the file dog?" "ls -al dog" ""

The file dog should be in current directory, or else mention the path.
Thanku Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

array as command line argument !!!!

hello, can any help me how to can pass array as command line argument in korn shell. also how to read a array from command line. thanks spandu (2 Replies)
Discussion started by: spandu
2 Replies

2. Shell Programming and Scripting

Capture entire line in ps command

I need to determine what processes are running at certain times of the day. I have a script that issues the /usr/ucb/ps aux command and captures it to a file. I want to see the cpu usage and memory usage. This command lops off the end of the of the display line so I can't see the entire... (2 Replies)
Discussion started by: MizzGail
2 Replies

3. Shell Programming and Scripting

How to get the value in last command line argument???

Say I want to get the value of last command line argument using the value in $# (or some other way if u can suggest) how do I do it?? $"$#" `$"$#"` These don't work :( (4 Replies)
Discussion started by: amit_oddey21
4 Replies

4. Shell Programming and Scripting

assign a command line argument and a unix command to awk variables

Hi , I have a piece of code ...wherein I need to assign the following ... 1) A command line argument to a variable e.g origCount=ARGV 2) A unix command to a variable e.g result=`wc -l testFile.txt` in my awk shell script When I do this : print "origCount" origCount --> I get the... (0 Replies)
Discussion started by: sweta_doshi
0 Replies

5. Programming

Command Line Argument

Hi, I have a very simple C program which will run in UNIX. When i am passing * as the command line argument, i am gettig the below output. Program: #include <stdio.h> #include "mylibrary.h" int **environ; int main(int argc,char *argv) { int i; printf("\nHello... (2 Replies)
Discussion started by: dsudipta
2 Replies

6. UNIX for Advanced & Expert Users

command to replace the entire line from the key point

Hi everyone I am new to Unix. I got stuck up by small issue. I have text file something like this abc 'xyz' '5' lmn 'pqr' '7' i want to replace the abc 'xyz' '5' to abc 'xyz' '6' but i have a key as 'xyz' based on this key i want to do that. I am not aware of how to use sed... (7 Replies)
Discussion started by: Vijayaragavan
7 Replies

7. UNIX for Advanced & Expert Users

Entire Input command not visible in Unix prompt

Hi, While typing the Unix command, entire command is not visible.When the input command is long, it is not visible. I want the entire command to be displayed when i type it. Please help to resolve this issue. Thanks Sampath (7 Replies)
Discussion started by: sampath.giri
7 Replies

8. Shell Programming and Scripting

Can a string be a command line argument?

I would like to use a string as a command line argument...is this possible using TCSH? For example say my script is called TEST and I would like to pass a string into my script stating why the test failed. EXAMPLE: TEST "Failed due to missing statement" (4 Replies)
Discussion started by: thibodc
4 Replies

9. Shell Programming and Scripting

Checking has for a command line argument

I would like to search and print a match of the user entered $ARGV. Im terrible with hashes and really dont know where to go from here. The example data file name location phone Bugs holeintheground 5551212 Woody holeinthetree 6661313 Jerry holeinthewall 7771414... (4 Replies)
Discussion started by: sumguy
4 Replies

10. UNIX for Beginners Questions & Answers

Command line argument

Hi Guys, I'm trying to work out how to add a command line argument inside single quotes. Would anyone be able to help please as I'm going mad :) I want to be able to place the filename on command line and it then be used in a script but it needs to have quotes surrounding it. Thanks in... (4 Replies)
Discussion started by: mutley2202
4 Replies
CipUX::Dog(3pm) 					User Contributed Perl Documentation					   CipUX::Dog(3pm)

NAME
CipUX::Dog - Adds a hook to CipUX::Task to execute commands. VERSION
This document describes CipUX::Dog version 3.4.0.0 SYNOPSIS
use CipUX::Dog; or use English qw( -no_match_vars); eval { require CipUX::Dog; }; if ( not $EVAL_ERROR ) { my $dog = CipUX::Dog->new( { dog_hr => $dog_hr, object => $object, overwrite_hr => $overwrite_hr, } ); $dog->bite(); # exec files system command } DESCRIPTION
CipuX::Dog can be used as a hook for CipUX::Task. If CipUX::Dog is installed it can be configured by the administrator to execute commands triggered by execution of a given task. SUBROUTINES
/METHODS BUILD Create the Object, reads the config file DEMOLISH Removes the object bite Calls the dog to bite. execute Execute a command. my $return = $self->execute( { command => $self->l($cmd), cmdargs_ar => $cmd_args_ar } ); DIAGNOSTICS
This section list every single error and warning message that the module can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. "The section "commands" is not defined in cipux-dog.perl for %s" The hash key 'commands' is not inside the configuration for a given dog hash key in cipux-dog.perl configuration. The problem might look like this: $cfg = { cipux_dogs => { create_homedir => { }, }, }; It can be solved by adding a 'commands' key: $cfg = { cipux_dogs => { create_homedir => { commands => { }, }, }, }; "Cannot execute [%s]. Please provide this command or change [cipux-dog.perl]. The error message was: %s" There can be different reasons for this message. It depends on the last %s. The following reasons are foreseen: "Command do not exist!" The command specified in cipux-dog.perl do not exist. You should copy, provide or write this command. "Command is not executable! (forget chmod +x ?)" The command specified in cipux-dog.perl exists but can not be executed. Either it has no executable flags or you have not the right to execute it. Check and/ro set the execution bit on this command or try do give you the right to execute it. "?" Other reasons not be able to execute the command might come from the system and will display after the message. "Can not close command %s" If the file handle can not be closed this message will be displayed. CONFIGURATION AND ENVIRONMENT
CipUX::Dog requires a configuration file but no environment variables. It can be configured by cipux-dog.$ext, where $ext is a valid and capable extension from CipUX configuration space. The default configuration for CipUX::Dog is in: /usr/share/cipux/etc/cipux-dog.perl DEPENDENCIES
Carp CipUX Class::Std Data::Dumper English Log::Log4perl Readonly version INCOMPATIBILITIES
None reported. BUGS AND LIMITATIONS
No bugs have been reported. SEE ALSO
See the CipUX webpage and the manual at <http://www.cipux.org> AUTHOR
Christian Kuelker "<christian.kuelker@cipworx.org>" LICENSE AND COPYRIGHT
Copyright (C) 2008 - 2009, Christian Kuelker. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. perl v5.12.3 2011-05-05 CipUX::Dog(3pm)
All times are GMT -4. The time now is 05:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy