05-29-2004
case statement based on file availability
I need to make a select menu that gives options dynamically based on whether certain files are available. For instance:
PS3="Open which readme? "
select readme in This That
do
case "$readme" in
This) open -a /Applications/TextEdit.app This.txt;;
That) open -a /Applications/TextEdit.app That.txt;;
* ) echo "Invalid selection";;
esac
done
}
The catch is that if the file doesn't exist, it should not show in the menu, either. I'm fairly new to shell scripting, so any help would be appreciated.
7 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to have an if statement in a script to run if there are certain processes running. Easiest way I can see to do this is to run a ps and grep the results based on what I am looking for:
$ ps -ef | grep wtrs
---
webtrend 5046 1 0 May 12 ? 0:28 /webtrends/versions/6.1/wtrs_ui... (6 Replies)
Discussion started by: LordJezo
6 Replies
2. Shell Programming and Scripting
hi all
i'm writing a script and in it i need to prompt the user if the entered value is correct or not ,i wrote the following and its not working ,its executing the script even if i enter Y/N
pls any help is appreciated
echo "\nAre you sure you entered the right Destination Environment? y :... (5 Replies)
Discussion started by: bkan77
5 Replies
3. Shell Programming and Scripting
I am writing a script to pull diskspace information from our servers. Here is the script that I wrote:
#!/bin/ksh
for host in `cat /oper/hosts/esc.misc`
do
ssh -q -o ConnectTimeout=10 operator@$host df -h|grep "/dev/" |egrep '8%|9%|100%' | awk '{print H " " "at " $5 " with " $4 "... (1 Reply)
Discussion started by: rkruck
1 Replies
4. Shell Programming and Scripting
Hello Unix Gurus :
It would be really appreciative if can find a solution for this .
I have records in a file .
I need to Capitalize the records based on condition .
For Example i tried the following Command
COMMAND -->
fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies
5. Shell Programming and Scripting
Hey, guys I really need some help with a project.
"Write a shell program that examines the command line arguments, counts and collects the number of options. Basically it has to collect and count the arguments that start with a "-" and the one's that don't start with a -
I know I have to use... (2 Replies)
Discussion started by: sk192010`
2 Replies
6. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Hey, guys I really need some help with a project.
"Write a shell program that examines the command line... (8 Replies)
Discussion started by: sk192010`
8 Replies
7. Shell Programming and Scripting
Linux System having all Perl, Python, PHP (and Ruby) installed
From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file
eg
eg
a Shell script run in a case statement call to run a php file, also Perl or/and Python file???
Like
#!/usr/bin/bash
....
....
case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
LEARN ABOUT PLAN9
dh_installmenu
DH_INSTALLMENU(1) Debhelper DH_INSTALLMENU(1)
NAME
dh_installmenu - install Debian menu files into package build directories
SYNOPSIS
dh_installmenu [debhelperoptions] [-n]
DESCRIPTION
dh_installmenu is a debhelper program that is responsible for installing files used by the Debian menu package into package build
directories.
It also automatically generates the postinst and postrm commands needed to interface with the Debian menu package. These commands are
inserted into the maintainer scripts by dh_installdeb(1).
FILES
debian/package.menu
Debian menu files, installed into usr/share/menu/package in the package build directory. See menufile(5) for its format.
debian/package.menu-method
Debian menu method files, installed into etc/menu-methods/package in the package build directory.
OPTIONS
-n, --no-scripts
Do not modify postinst/postrm scripts.
SEE ALSO
debhelper(7) update-menus(1) menufile(5)
This program is a part of debhelper.
AUTHOR
Joey Hess <joeyh@debian.org>
11.1.6ubuntu2 2018-05-10 DH_INSTALLMENU(1)