Running set options from the command line and bash command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Running set options from the command line and bash command
# 1  
Old 07-27-2011
Running set options from the command line and bash command

I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing

set [option]

you can also use them "on the command line when running a script..." and it lists this in a small table:


set -o option Command Line option
noexec -n
verbose -v
xtrace -x

I know how to set the options in the first column, but how are the options in the second column used? I've tried typing the name of the script followed by the option and vice versa, but only the results of the script are displayed on the screen. Can someone tell me what I'm doing wrong, or am I misunderstanding something?

The book I'm using is "Learning the bash shell" if that helps, 3rd edition, page 222 halfway down under "set options"

Also, on the following page, when illustrating how to find a bug in program, it lists the command

bash -v scriptname

when looking for the bug.

what does the command bash do exactly? I haven't encountered this command before in this context and am not sure what's going on.
# 2  
Old 07-27-2011
Quote:
Originally Posted by Straitsfan
I know how to set the options in the first column, but how are the options in the second column used?
for example, set -n
# 3  
Old 07-27-2011
Hey there,

I'm not quite sure about your first question, however to debug a bash shell script the command is thus;

# bash -x <script name>
# 4  
Old 07-27-2011
Corona --

What I meant was on the command line you can use set [option as a word] to turn it on or off, and then run a script to see the results. But what I was wondering is how to use the other option on the command line. I tried

set -v testscript

and nothing happened (it works fine if I type set -o verbose testscript, for example.] If I tried the scriptname first and then the one letter option, I get an error message. So I was confused as to how to use just the one letter option on the command line -- or is that how it's done when you use the command bash?

I hope that's clearer.

And what exactly does the command 'bash' do?
# 5  
Old 07-27-2011
Quote:
Originally Posted by Straitsfan
Corona --

What I meant was on the command line you can use set [option as a word] to turn it on or off, and then run a script to see the results. But what I was wondering is how to use the other option on the command line. I tried

set -v testscript

and nothing happened (it works fine if I type set -o verbose testscript, for example.] If I tried the scriptname first and then the one letter option, I get an error message. So I was confused as to how to use just the one letter option on the command line -- or is that how it's done when you use the command bash?

I hope that's clearer.

And what exactly does the command 'bash' do?
Hi you asked how to find a bug / debug a script, if it's a bash script then the command would be;

# bash -x scriptname.bash

korn shell script

# ksh -x scriptname.ksh

etc

William
# 6  
Old 07-28-2011
Quote:
Originally Posted by Straitsfan
set -v testscript
set works inside a shell, it doesn't change options for another shell, or options for a program which hasn't even been run yet.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Another one line command where I'd like to determine if Ubuntu or Red Hat when running command

Hello Forum, I'm making very good progress on my report thanks to the very helpful people on this forum. I've been able to successfully create my report for my Red Hat servers. But I do have a few ubuntu servers in the mix and I'd like to capture some data from them when an ssh connection is... (8 Replies)
Discussion started by: greavette
8 Replies

2. Shell Programming and Scripting

Passing new options to a running command

I was just wondering if there is a way to pass an new option or argument to an already running command or program. Let us say you run "zenity --list <options>" and you like to add a title or change the title you used on it while it is already running, is it possible to do that? (1 Reply)
Discussion started by: cryogrid
1 Replies

3. Shell Programming and Scripting

Processing Multiple Arguments in Command Line Options

Hi All, I am new to scripting. Could you please assist me . Here is my requirement. I have written a script that has 2 option flags defined. -l) calls some function with the arguments passed in front of -l -r) calls second function with the arguments passed in front of -r *) calls the... (7 Replies)
Discussion started by: Jay Deshpande
7 Replies

4. UNIX for Dummies Questions & Answers

Display full command (including options) information in running

Suppose I am a Unix user, not a root. I can see all commands in running by ps -elf, or some similar commands. Such commands may be submit by other Unix users. Is there a way that I can display those commands with their full parameters/options. For example, I can see a user is running "ls"... (3 Replies)
Discussion started by: happy_lotus
3 Replies

5. Shell Programming and Scripting

Reading command line options from bash script

I have the following code and I am calling it using ./raytrac.bash -u and getting problems. For some reason opt_usage is still 0. opt_usage=0 iarg=0 narg=$# while (($iarg < $narg)) do (( iarg = $iarg + 1 )) arg=$argv usrInputFlag=`echo $arg | awk '/=/ {print 1}; ! /=/... (22 Replies)
Discussion started by: kristinu
22 Replies

6. Shell Programming and Scripting

awk script file command line options

Being new to awk I have a really basic question. It just has to be in the archives but it didn't bite me when I went looking for it. I've written an awk script, placed it in a file, added the "#!/usr/bin/awk -f" at the top of the script and away I go. "% myAwk <inputfile>" gives me exactly what... (2 Replies)
Discussion started by: tomr2k
2 Replies

7. Shell Programming and Scripting

Using perl to get options from command line

Hi all, I want to get options from command line by perl. usage() options: -h Show this help message and exit -t Name of tester --timeout Set the timeout -l ... (1 Reply)
Discussion started by: Damon_Qu
1 Replies

8. Shell Programming and Scripting

how to? launch command with string of command line options

my description from another thread... here's my code: #!/bin/bash IFS=$'\n' function OutputName() { input=$1 echo $input input=`echo "$input" | sed -e 's/.//'` input=`echo "$input".avi` output_name=$input } if ]; then echo... (5 Replies)
Discussion started by: TinCanFury
5 Replies

9. Shell Programming and Scripting

Associated array from command line options

I am looking to populate an (associated) array with a command line argument. The command line would look something like this: alert -action test -priority '10' -module test_module . . . The associated array would look like this after the data is read in flag=(action=test priority=10... (1 Reply)
Discussion started by: jperret
1 Replies

10. Programming

Executing command line options

Can someone please tell me how to modify/add to this code so that it recognizes UNIX command options (all beginning with "-") and executes the command with options? #include<stdio.h> #include<stdlib.h> int main(int argc, char *argv) { int i; system("stty -echo"); ... (8 Replies)
Discussion started by: Safia
8 Replies
Login or Register to Ask a Question