1819899 Members
2560 Online
109607 Solutions
New Discussion юеВ

Board Graphics Script

 
SOLVED
Go to solution
Jeffrey W. Stewart
Frequent Advisor

Board Graphics Script

I need information on scripts. I would like a script that would allow a user to select from a menu and then run board graphics. The menu would be something like this:

1. 724781 Board Graphics
2. 724785 Board Graphics
3. 724791 Board Graphics

The command 'board graphics' is normally executed in the BT-BASIC window. In a BT-BASIC window the command is MSI '/hp3070/boards/724781/board graphics' and that would display the board graphics for that board. Can such a script be made? Do scripts have a file extension like the MSDOS Batch files? How do you start a script? Thanks.

hp3070 with B180L, hpux 10.2x.


6 REPLIES 6
Jeffrey W. Stewart
Frequent Advisor

Re: Board Graphics Script

Should this have been asked in a different forum? I can't even get a simple script to work.
#!/bin/sh
if ["$1"]
then
echo "Found an argument to this script"
if [ $1="fred"]
then
echo "the argument was fred"
else
echo "the argument was not fred"
fi
else
echo "This script needs one argument
fi
Jared Westgate_1
Valued Contributor

Re: Board Graphics Script

Hello Jeffrey,

I don't know what a board graphic is, but I think I can help you with your script. I apologize if I'm being too basic, but here is my understanding (although I am still a beginner)... First, unix doesn't use filename extensions to specify what type of file it is (that's one of the things that makes it "virus-proof"). In order to make a file executable, it needs to have the correct access permissions. When you do an "ls -l", the first column will show the access permissions. For example:

-rwxr-xr-x 1 jwestgat mis testfile

the first "-" in the example is basically the type of object it is (d for directory, l for link, - for a normal file). The next three are the permissions for the owner (r=read, w=write, x=execute). Then next three are for the group, the last three are for everybody else. Basically, you need to make sure you have an x permission if you want to execute a file. In my example, all users could execute the "testfile" program.

Second, if you want to actually run the script, you use the "." command. Type in "./testfile" to run the command in my example.

Finally, I think there may be a few small synax errors in your program, give this a try:

#!/bin/sh
if [ "$1" ]
then
echo "Found an argument to this script"
if [ $1="fred" ]
then
echo "the argument was fred"
else
echo "the argument was not fred"
fi
else
echo "This script needs one argument"
fi

I hope this has helped, please let me know if I missed anything.

Jared
Jeffrey W. Stewart
Frequent Advisor

Re: Board Graphics Script

Jared,
Your reply helped me with starting to write scripts. I realize now the [ is the same as Test. I would like to present a menu and then have board graphics displayed for that choice. I know the command to display board graphics, so I just need to get the menu and menu selection working. I believe I need to use a read command.
Jared Westgate_1
Valued Contributor

Re: Board Graphics Script

Hey Jeffrey,

I use the read command to take input from the keyboard. There are probably others, but this is the only one I know. I put together a little script that might help you. I don't know if this will help you much, I'm certainly not a scripting expert. Here it is:

# variables
MENUCHOICE=0

# execution
clear
echo " "
echo " Please choose and option below, by typing in the number:"
echo " 1) Display Board Graphic 1"
echo " 2) Display Board Graphic 2"
echo " 3) Exit"

read MENUCHOICE

case "$MENUCHOICE" in
1) clear
echo "This is Board Graphic #1";;
2) clear
echo "This is Board Graphic #2";;
3) echo "exiting..."
exit 0;;
*) echo "Please choose a number!";;
esac

echo "Complete"
Jared Westgate_1
Valued Contributor
Solution

Re: Board Graphics Script

I hope nobody minds me posting so much, but I thought of a better way to do the menu thing....

# variables
MENUCHOICE=0
EXITVALUE=1

# functions
dspmenu1 ()
{
clear
echo ""
echo " Please choose and option below, by typing in the number:"
echo " 1) Display Board Graphic 1"
echo " 2) Display Board Graphic 2"
echo " 3) Exit"
read MENUCHOICE
}

readchoice ()
{
case "$MENUCHOICE" in
1) clear
echo "This is Board Graphic #1"
EXITVALUE=0;;
2) clear
echo "This is Board Graphic #2"
EXITVALUE=0;;
3) echo "exiting..."
EXITVALUE=0;;
*) echo "Please choose a number from the list!"
sleep 1
EXITVALUE=1;;
esac
}

# Execution
while [ $EXITVALUE != 0 ]
do
dspmenu1
readchoice
done

echo "Complete"
Jeffrey W. Stewart
Frequent Advisor

Re: Board Graphics Script

Solution is in the Thread