Sponsored Content
Top Forums Shell Programming and Scripting Passing Command Line Args in a Single Variable? Post 302685859 by mrm5102 on Monday 13th of August 2012 12:33:24 PM
Old 08-13-2012
Hey Corona688, thanks for the reply.

Ok, that makes sense about there being a security risk for that...

The reason why I wanted to do that was because, like I mentioned in the OP, I have a bunch of
differnet possibilites for the optional command line args. Which in turn means a ton of differnt
combinations of arguments are possible. And because of that I would need a bunch of if statemnts
to check for these combinations (which is what I originally had)...

For example: Lets say that some of Optional Arguments are:
$option='start|stop|restart|status|add' --> Required Argument so $option will be on the executing line no matter what
command="..."
comment="..."
--restart
etc...

So for just these three args I would need all these If Statements...
Code:
if [[ $option =~ add ]]
 then
    if [ $comment -eq 1 ]
     then
        if [ $restart_option -eq 1 ]
         then
            /path/to/script/myExpect_script $ip_address $username $password $option command="..." comment="..." --restart --sshed
        elif [ $restart_option -eq 0 ]
         then
            /path/to/script/myExpect_script $ip_address $username $password $option command="..." comment="..." --sshed
        fi
    elif [ $comment -eq 0 ]
     then
        if [ $restart_option -eq 1 ]
         then
            /path/to/script/myExpect_script $ip_address $username $password $option command="..." --restart --sshed
        elif [ $restart_option -eq 0 ]
         then
            /path/to/script/myExpect_script $ip_address $username $password $option command="..." --sshed
    fi
fi

As you can see in the code above, this can get pretty messy, and that's only 3 of the options
that I'm checking in this example...

Since you said there's a security risk in doing it the way I was suggesting. Maybe I could just parse that option
that was passed from bash (i.e. $exe_command_args) and split it on whitespace, or something like that from
within the Expect Script..?


Thanks Again,
Matt
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing the command line argument in a variable

Hi, I am new to unix. Is their a way to pass the output of the line below to a variable var1. ls -1t | head -1. I am trying something like var1=ls -1t | head -1, but I get error. Situation is: I get file everyday through FTP in my unix box. I have to write a script that picks up first... (1 Reply)
Discussion started by: rkumar28
1 Replies

2. UNIX for Dummies Questions & Answers

required command line args

Hello, How do I make a command line argument required using getopts? Thanks. (6 Replies)
Discussion started by: yoi2hot4ya
6 Replies

3. Programming

Command line args

My program usage takes the form for example; $ theApp 2 "one or more words" i.e. 3 command line arguments; application name, an integer, some text My code includes the following 4 lines: int anInteger; char words; sscanf(argv, "%d", &anInteger); sscanf(argv, "%s", &message); Based... (2 Replies)
Discussion started by: enuenu
2 Replies

4. UNIX for Dummies Questions & Answers

command line args

I am trying to print command line arguments one per second. I have this while do echo "6" shift echo "5" shift echo "4" shift echo "3" shift echo "2" shift echo "1" shift done (2 Replies)
Discussion started by: skooly5
2 Replies

5. UNIX for Dummies Questions & Answers

command line args 2

I have this while loop and at the end I am trying to get it to tell me the last argument I entered. And with it like this all I get is the sentence with no value for $1. Now I tried moving done after the sentence and it printed the value of $1 after every number. I don't want that I just want... (2 Replies)
Discussion started by: skooly5
2 Replies

6. Shell Programming and Scripting

How to retrieve command line args one by on.

Hi, I have to store all the command line arguments into an array. I have the following code. ********************** #! /bin/sh set -A arr_no_updates i=1 while do arr_no_updates=$($i) echo ${arr_no_updates} i=$(($i+1)) done**************** (1 Reply)
Discussion started by: little_wonder
1 Replies

7. Shell Programming and Scripting

command line args in unix

Hi, i have a perl script named test.pl. It is executed as cat *.log|test.pl i need the complete command line args. I tried using basename $0 but im getting test.pl only but not cat *.log... Can anyone help me on this. Thanks in advance (3 Replies)
Discussion started by: niteesh_!7
3 Replies

8. Emergency UNIX and Linux Support

Cut | command line args

Hi, Can you please hint me how to achieve the below? Input: $./script.sh start 1 2 Internally inside the script i want to set a single variable with $2 and $3 value? Output: CMD=$1 ARGS=$2 $3 --VInodh (10 Replies)
Discussion started by: vino_hymi
10 Replies

9. Shell Programming and Scripting

Reading of variable in a single line command

Hi All, Below is a sample command that I can run without any problem in the command line. Command Line dtToday=`date +%Y%m%d`; ls -ltr ./filename_${dtToday}.txt -rw-r--r-- 1 monuser oinstall 0 Jan 18 11:02 ./filename_20130118.txt But once I put that command line in file (list.txt) and... (3 Replies)
Discussion started by: padi
3 Replies

10. Shell Programming and Scripting

Passing the value of variable which is read from command line in called script

Hi, I am calling a Perl script in my shell script. When Perl script is executed it asks for a answer to be entered by user from terminal. How can i pass that value from my shell script ?? I know I can change perl script to default the answer but i dont have access to do that so only option i... (5 Replies)
Discussion started by: varun22486
5 Replies
ttk::checkbutton(3tk)						 Tk Themed Widget					     ttk::checkbutton(3tk)

__________________________________________________________________________________________________________________________________________________

NAME
ttk::checkbutton - On/off widget SYNOPSIS
ttk::checkbutton pathName ?options? _________________________________________________________________ DESCRIPTION
A ttk::checkbutton widget is used to show or change a setting. It has two states, selected and deselected. The state of the checkbutton may be linked to a Tcl variable. STANDARD OPTIONS
-class -compound -cursor -image -state -style -takefocus -text -textvariable -underline -width See the ttk_widget manual entry for details on the standard options. WIDGET-SPECIFIC OPTIONS Command-Line Name:-command Database Name: command Database Class: Command A Tcl script to execute whenever the widget is invoked. Command-Line Name:-offvalue Database Name: offValue Database Class: OffValue The value to store in the associated -variable when the widget is deselected. Defaults to 0. Command-Line Name:-onvalue Database Name: onValue Database Class: OnValue The value to store in the associated -variable when the widget is selected. Defaults to 1. Command-Line Name:-variable Database Name: variable Database Class: Variable The name of a global variable whose value is linked to the widget. Defaults to the widget pathname if not specified. WIDGET COMMAND
In addition to the standard cget, configure, identify, instate, and state commands, checkbuttons support the following additional widget commands: pathname invoke Toggles between the selected and deselected states and evaluates the associated -command. If the widget is currently selected, sets the -variable to the -offvalue and deselects the widget; otherwise, sets the -variable to the -onvalue Returns the result of the -command. WIDGET STATES
The widget does not respond to user input if the disabled state is set. The widget sets the selected state whenever the linked -variable is set to the widget's -onvalue, and clears it otherwise. The widget sets the alternate state whenever the linked -variable is unset. (The alternate state may be used to indicate a "tri-state" or "indeterminate" selection.) STANDARD STYLES
Ttk::checkbutton widgets support the Toolbutton style in all standard themes, which is useful for creating widgets for toolbars. SEE ALSO
ttk::widget(3tk), ttk::radiobutton(3tk), checkbutton(3tk) KEYWORDS
widget, button, toggle, check, option Tk 8.5 ttk::checkbutton(3tk)
All times are GMT -4. The time now is 04:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy