12-13-2001
newb shell question
I know this is a total begginer question but what is wrong with this picture. My loop wont loop, it just drops me back to the prompt and gives the error "unary operator expected". Any help would be appreciated.
here it is,
#!/bin/sh
selection=
while [ $selection -ne9 ]
do
cat << MENU
1)List files in current directory
2)Display pwd
3)Remove a directory
4)Create a directory
5)Copy a file
6)Remove a file
7)Change directory
8)Mail file to user
9)EXIT
MENU
echo "Enter selection:\c"
read selection
echo "the user selected option $selection"
if [ $selection -eq 1 ]
then
ls
elif [ $selection -eq 2 ]
then
pwd
elif [ $selection -eq 3 ]
then
echo "Name of dir to delete"
read option3
rm -r $option3
elif [ $selection -eq 4 ]
then
echo "Name of dir to create"
read option4
mkdir $option4
elif [ $selection -eq 5 ]
then
echo "Name of file to copy"
read option5
echo "Where to move it to?"
read option55
cp -r $option5 $option55
elif [ $selection -eq 6 ]
then
echo "Name of file to delete"
read option6
rm -r $option6
elif [ $selection -eq 7 ]
then
echo "Name of directory to change to"
read option7
cd $option7
pwd
elif [ $selection -eq 8 ]
then
echo "Name of file to send"
read option8
echo "Who to send it to"
read option88
mailx $option8 < $option88
elif [ $selection -eq 9 ]
then
exit
else
echo "Please enter a valid selection"
fi
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
ok i just installed FreeBSD 4.8 on a computer i had lying around and it was working ok but then when i tried to set up KDE's xdm (kdm) i think i must have configured the login manager wrong because i cant login through the kdm and therefore i can log in to BSD at all?!
please can someone help me... (5 Replies)
Discussion started by: h3x
5 Replies
2. UNIX for Dummies Questions & Answers
I don't even know if this should go here but I just would like to know what this means:
d0e45878043844ffc41aac437e86b602
I know absolutely nothin' about UNIX, and I found this in a SQL table in a board I run.
Someone please tell me what that is in "normal" mode.
Pardon me for my... (4 Replies)
Discussion started by: daeglin
4 Replies
3. UNIX for Dummies Questions & Answers
I am wanting to download the Linux Program. When i go to download it I see several things to download. What do i download exactly? Then what do I do to install it. Also I have partitioned my hard drive to make way for Linux on the other part to play with it, will any problems arise from this?
I... (3 Replies)
Discussion started by: Seeto
3 Replies
4. Shell Programming and Scripting
This is probably a really simple problem, but goes easy on me I'm still a newb. The problem I have is that a script (we'll call it script.script) I edited won't run for some reason, I get the error "ksh: script.script: not found"
The location of my script is as follows: /home/users/arkitech
... (3 Replies)
Discussion started by: Arkitech
3 Replies
5. Shell Programming and Scripting
Assume $x equals "".
If I try:
if test -n $x
I get the "Expression syntax" error.
It works in Linux but not in unix bash. In unix bourne I get "test: argument expected" (4 Replies)
Discussion started by: lumix
4 Replies
6. Shell Programming and Scripting
My first post here....
I have a few years exp with linux distros and some very basic Python..Ive been intent on learning shell scripting the last few weeks. Please excuse my crude efforts.
I am running a program that takes network data containing US city names in plain text. I am TRYING to... (7 Replies)
Discussion started by: dddkkk
7 Replies
7. HP-UX
Hello, I am totally new to Unix
We have a piece of test equipment, three of them actually, that run HP-UX 9.0 from like 1994. We had backup tapes with procedures to load the OS and our test software, but the 16-track tapes are corrupt now. HP will not support it, they dont have it anymore,... (11 Replies)
Discussion started by: Newball80
11 Replies
8. UNIX for Dummies Questions & Answers
Hey!
This is my first post on this forum, nice to meet ya!
I've been using Linux for a good few years, I grew up using DOS and a few similar CLI-based OS's so I'm fairly okay with navigating my way around the terminal. Recently I decided I wanted to become a sysadmin so I've been teaching... (3 Replies)
Discussion started by: Tamachan87
3 Replies
9. Shell Programming and Scripting
Hi everyone.
I am new to shell scripting and have been looking at quite a few web pages to try and figure this out, but to no avail.
What I am trying to do is get a value from a text file that contains a paragraph of information.. Something similar too:
Welcome to random script
You are... (1 Reply)
Discussion started by: elemenopee
1 Replies
10. UNIX for Dummies Questions & Answers
This should be extremely simple and someone will probably answer it in .5 seconds. I need to know what:
VARIABLE=${0##*/}
does? I do not have a shell handy to just try it in. I am reading through some scripts and need to understand this line. Any help is appreciated.
Many thanks!
-... (3 Replies)
Discussion started by: chrisgoetz
3 Replies
LEARN ABOUT HPUX
xtloseseleb
XtLoseSelectionProc() XtLoseSelectionProc()
Name
XtLoseSelectionProc - interface definition for procedure to notify the selection owner it has lost selection ownership.
Synopsis
typedef void (*XtLoseSelectionProc)(Widget, Atom *);
Widget w;
Atom *selection;
Inputs
w Specifies the widget that has lost selection ownership.
selection Specifies the atom that names the selection.
Description
An XtLoseSelectionProc is optionally registered in a call to XtOwnSelection() and is called by the Intrinsics when the widget it was regis-
tered with loses the selection because another widget or client has claimed the selection. It is not called when the selection owner
relinquishes selection ownership with XtDisownSelection(). This procedure should take whatever action is appropriate for the widget or
application when it loses selection ownership.
Note that this procedure is not a request to the widget to relinquish selection ownership; it is called after the widget has already lost
the selection.
Usage
Most selection owners (widgets or applications) will want to display selected data highlighted in some way, and so will need to be informed
when they lose the selection so that they can unhighlight that data.
An XtLoseSelectionIncrProc is a similar procedure type used by the Intrinsics incremental selection transfer mechanism. It takes an addi-
tional client_data argument.
Example
The XtLoseSelectionProc below is from the xcalc client. It simply unhighlights the value currently shown in the calculator display.
/*
* called when xcalc loses ownership of the selection.
*/
/*ARGSUSED*/
void lose(w, selection)
Widget w;
Atom *selection;
{
XawToggleUnsetCurrent(LCD);
}
See Also
XtDisownSelection(1), XtGetSelectionValue(1), XtGetSelectionValueIncremental(1), XtOwnSelection(1),
XtLoseSelectionIncrProc(2).
Xt - Selections XtLoseSelectionProc()