- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- common problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 10:03 PM
тАО04-23-2003 10:03 PM
common problem
2. how can we make sure the variable is not reset?
3. what command can be used in script to lock terminal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 10:12 PM
тАО04-23-2003 10:12 PM
Re: common problem
and based on youre shell, use an echo $? (ksh, bash, sh etc) and echo $status (csh and tcsh (?)) to know the status.
2. not very clear. variables are there to be set and reset. use set or setenv or export based on your shell and if u need a local or a global variable.
3. how abt scrolling through a loop and read for a passwd and wait until the correct passwd is entered.
hth
-balaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 10:33 PM
тАО04-23-2003 10:33 PM
Re: common problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 10:52 PM
тАО04-23-2003 10:52 PM
Re: common problem
If a command completes successfully, it returns a 0 exit.
In most shells (bash, ksh, ash, sh) you can do conditionals upon the exit state, without having to do an 'if' check on the exit value. For example:
grep -q root /etc/passwd && echo "I found root in /etc/passwd"
When 'grep' successfully find a pattern in a file, it will return 0. The '&&' operator states that if there is a successful exit, that the following command should be executed (in this case a simple 'echo').
Using {} and () allows you to make this more complicated.
Other things you can do is to make 'if' descisions directly based upon the exit of a program, rather than checking the $? exit values, for example:
if grep -q root /etc/passwd
then
echo "I found root in the passwd file"
fi
This can also be negated:
if ! grep -q root /etc/passwd
then
echo "I couldn't find root in the passwd file"
fi
Most people however use the program 'test' to do such checking. '/usr/bin/test' is usually symbolically linked to '/usr/bin/[' (thus the format:
grep -q root /etc/passwd
if [ $? -gt 0 ]
then
echo "I couldn't find root in the passwd file"
fi
)
... umm, sorry .. ramble ..
2) Using ksh and bash, you can use the command 'typeset' (in-built shell-function), with the flag '-r' to mark a variable 'read-only'. It cannot be changed or un-marked as read-only, until the shell is destroyed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 10:55 PM
тАО04-23-2003 10:55 PM
Re: common problem
trap "" 1 2 15
makes your script not respond to a SIGHUP (1), a SIGINT (2, ctrl-c) or SIGTERM (15).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2003 11:42 PM
тАО04-23-2003 11:42 PM
Re: common problem
The command arg is to be read and executed when the shell
receives signal(s) sigspec. If arg is absent or -, all speci-
fied signals are reset to their original values (the values they
had upon entrance to the shell). If arg is the null string the
signal specified by each sigspec is ignored by the shell and by
the commands it invokes. If arg is not present and -p has been
supplied, then the trap commands associated with each sigspec
are displayed. If no arguments are supplied or if only -p is
given, trap prints the list of commands associated with each
signal number. Each sigspec is either a signal name defined in
command arg is executed on exit from the shell. If a sigspec is
DEBUG, the command arg is executed after every simple command
(see SHELL GRAMMAR above). If a sigspec is ERR, the command arg
is executed whenever a simple command has a non-zero exit sta-
tus. The ERR trap is not executed if the failed command is part
of an until or while loop, part of an if statement, part of a &&
or || list, or if the command's return value is being inverted
via !. The -l option causes the shell to print a list of signal
names and their corresponding numbers. Signals ignored upon
entry to the shell cannot be trapped or reset. Trapped signals
are reset to their original values in a child process when it is
created. The return status is false if any sigspec is invalid;
otherwise trap returns true.
man sh or ksh and search for trap.
-balaji