How to use case and command line arguments in shell script?
Hi... can anyone please help me out in using the CASE and command line argument in shell script... i am bit new to shell scripting...below i have explained my proble with example...
say i have an executable file with name 'new1.sh' and there are 3 functions in it a(), b() and c()....and there is 1 function Options().. so the file looks like this...
new1.sh
now i want to use the above file using the below command format..
so that all the 3 functions are called by this command... and the user should have freedom to give as many options as he wishes to.... like he can give only 1 command line arg...
OR 2 arg like..
can anyone please help me in writing this code...
---------- Post updated at 11:50 PM ---------- Previous update was at 11:25 PM ----------
hi....
can anyone plesae help me in this quickly...
thanks in advance...
Last edited by Scott; 03-23-2011 at 03:49 PM..
Reason: Code tags, please...
Dear forum
I have the following small script:
#!/bin/ksh
echo -e "abba-o" | awk -F '-' '{ print $2 }' | cut -b 1It needs to be ksh.. in bash I don't have this problem.
If I run this on opensuse 10.2 I get this as output: e
If I run this on suse enterprise 10 sp2 then I get this: o
... (1 Reply)
I have no idea what the following means. The teacher is too advanced for me to understand fully. We literally went from running a few commands over the last few months to starting shell scripting. I am not a programmer, I am more hardware oriented. I wish I knew what this question was asking... (3 Replies)
Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script?
The output should be something like this:
User userid has a home directory of /path/directory
the default shell for this user is /path/shell (1 Reply)
Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script?
The output should be something like this:
User userid has a home directory of /path/directory
the default shell for this user is /path/shell (1 Reply)
Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script?
The output should be something like this:
User userid has a home directory of /path/directory
the default shell for this user is /path/shell (5 Replies)
Hello All,
i am known to the limitation of different shells while passing more than 9 command line arguments
i just tried the example below
i do see my current shell is tcsh
echo $SHELL
/bin/tcsh
so if i make my script executable and run it
output is
... (6 Replies)
hi,
I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script.
e.g.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv)
{ int i;
for (i=1;i<argc; i++)
{
... (2 Replies)
Hi guys,
I am having trouble with this script. What i want it to do is to iterate all command line arguments in reverse order. The code below does this fine but i need the output to print the words on separate lines instead of one line:
#!/bin/bash
#Takes in the arguments and displays them... (7 Replies)
]I have a string like "/abc/cmind/def/pq/IC.2.4.6_main.64b/lnx86" and this string is given by user. But in this string instead of 64b user may passed 32 b an i need to parse this string and check wether its is 32b or 64 b and according to it i want to set appropriate flags.
How will i do this... (11 Replies)
Hi
Am pretty new to C..
Am trying to pass the arguments from command line and use them in switch case statement..
i have tried the following
#include <stdlib.h>
main(int argc, char* argv)
{
int num=0;
if ( argc == 2 )
num = argv;
printf("%d is the num value",num);
switch ( num )
... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies
LEARN ABOUT REDHAT
code
code(n) [incr Tcl] code(n)
NAME
code - capture the namespace context for a code fragment
SYNOPSIS
code ?-namespace name? command ?arg arg ...?
DESCRIPTION
Creates a scoped value for the specified command and its associated arg arguments. A scoped value is a list with three elements: the
"@scope" keyword, a namespace context, and a value string. For example, the command namespace foo {
code puts "Hello World!" } produces the scoped value: @scope ::foo {puts {Hello World!}} Note that the code command captures the cur-
rent namespace context. If the -namespace flag is specified, then the current context is ignored, and the name string is used as the
namespace context.
Extensions like Tk execute ordinary code fragments in the global namespace. A scoped value captures a code fragment together with its
namespace context in a way that allows it to be executed properly later. It is needed, for example, to wrap up code fragments when a Tk
widget is used within a namespace: namespace foo {
private proc report {mesg} {
puts "click: $mesg"
}
button .b1 -text "Push Me" -command [code report "Hello World!"]
pack .b1 } The code fragment associated with button .b1 only makes sense in the context of namespace "foo". Furthermore, the "report"
procedure is private, and can only be accessed within that namespace. The code command wraps up the code fragment in a way that allows it
to be executed properly when the button is pressed.
Also, note that the code command preserves the integrity of arguments on the command line. This makes it a natural replacement for the
list command, which is often used to format Tcl code fragments. In other words, instead of using the list command like this: after 1000
[list puts "Hello $name!"] use the code command like this: after 1000 [code puts "Hello $name!"] This not only formats the command cor-
rectly, but also captures its namespace context.
Scoped commands can be invoked like ordinary code fragments, with or without the eval command. For example, the following statements work
properly: set cmd {@scope ::foo .b1} $cmd configure -background red
set opts {-bg blue -fg white} eval $cmd configure $opts Note that scoped commands by-pass the usual protection mechanisms; the command:
@scope ::foo {report {Hello World!}} can be used to access the "foo::report" proc from any namespace context, even though it is private.
KEYWORDS
scope, callback, namespace, public, protected, private
itcl 3.0 code(n)