Sponsored Content
Full Discussion: Creating a PATH variable
Top Forums Shell Programming and Scripting Creating a PATH variable Post 303027944 by Circuits on Friday 28th of December 2018 12:02:55 PM
Old 12-28-2018
Sure yeah you guys have all been a great help so far, thanks. I will go ahead and show the script here. I have commented it to show what I understand and what I do not understand. Note that my comments are marked with // to differenciate them from the preexisting comments:
Code:
#!/bin/sh 
# Sound Manager 
#

### BEGIN INIT INFO
# Provides:          soundmanager
# Required-Start:    $local_fs $remote_fs $syslog $network
# Required-Stop:     $local_fs $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Sound Manager
# Description:       Start the Sound Manager daemon
### END INIT INFO


PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/entity/bin //designate the various path's so that the shell knows where to look for executable's
data_dir=/usr/local/entity/project //designate a location where the shell can store information (does not seem to be used in the script)
SOUNDMANAGER=bmsoundmanager //give the bmsoundmanager a variable or an alias in this case "SOUNDMANAGER" the bmsoundmanager 
                            //is a program within entity/bin which controls various aspects
                            //of the sound system, it is an extension of SoundManagerAlsa

 
start() { //the "start" function, first statement in the case statement 
    echo -n "Starting Sound Manager:             " //print statement, will not output the trailing newline
    # Enable audio amplifier mode input
    echo 107 > /sys/class/gpio/export //not completely sure what this does, it might compare the value 107 to a value found in the export directory
    # Mute the amplifier
    echo 0 > /sys/class/gpio/gpio107/value //again not completely sure what this does
      ( ${SOUNDMANAGER} -q -n& ) && echo '[ OK ]' || echo '[FAIL]' //start the bmsoundmanager and feed it the
                                                                   //conditions -q (quiet = true: debug output is muted) and -n (detach = false: do not run as a daemon) 
                                                                   //&& means 'and' while || means 'or'
                                                                    //I am not sure how the program knows to echo OK versus FAIL
}

 
 
stop() { //the "stop" function, second statement in the case statement
    echo -n "Stopping Sound Manager:             " //print statement, will not output the trailing newline
    killall -HUP ${SOUNDMANAGER} //stops the program from running; however, H U P aren't in the man pages for the killall command so I am not sure what they do
}

//Here we have the case statement or the conditional logic. The first condition being that a user entered the command: 'start' and the second being
//that the user entered 'stop' when running the shell. 
case "$1" in
"start")
        start
        ;;
"stop")
        stop
        echo "OK"
    ;;
reload|restart)
        stop
        sleep 1
        start
    ;;
*)
    echo "$0: unknown argument $1." >&2;
    ;;
esac

#

EDIT: I hope the formatting shows up the same on your computer screens as it does on mine. I had some trouble formatting my comments so that it looks neat but you never know how it will appear to other users.

Last edited by Circuits; 12-28-2018 at 02:06 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Creating alias for directory path

I am trying to create an alias for a frequently used directory path by using alias xyz="/proj/dir_name" and then trying to reach a sub-directoy by using cd xyz/abc but I get an error saying " No such file or directory " plz tell me wats wrong with this ... (3 Replies)
Discussion started by: jasjot31
3 Replies

2. UNIX for Dummies Questions & Answers

creating a variable

I cannot seem to get the following script to work. I cannot seem to set the variable. What am I missing? bin/bash set -x echo "2" > /tmp/number STATUS='grep -c 2 /temp/number' if ; then echo "Number 2 is found once" else echo "Number 2 is found more or less than one time" fi (3 Replies)
Discussion started by: rexmabry
3 Replies

3. Shell Programming and Scripting

Getting the path from a variable

Hi, I am having a variable Like line="/dir1/dir2/gr3/file.ksh" I need to get the /dir1/dir2/gr3 alone. the no of directories may differ at each time. Please advice. thanks in advance. (3 Replies)
Discussion started by: vanathi
3 Replies

4. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

5. Shell Programming and Scripting

remove a path from PATH environment variable

Hi I need a script which will remove a path from PATH environment variable. For example $echo PATH /usr/local/bin:/usr/bin:test/rmve:/usr/games $echo rmv test/rmve Here I need a shell script which will remove rmv path (test/rmve) from PATH... (9 Replies)
Discussion started by: madhu84
9 Replies

6. Shell Programming and Scripting

one liner to extract path from PATH variable

Hi, Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable? for eg: suppose the PATH is being set as follows PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4 ... (2 Replies)
Discussion started by: royalibrahim
2 Replies

7. Shell Programming and Scripting

Appending a path in user's PATH variable

Hello Folks, I want to append a path in user's PATH variable which should be available in current session. Background Numerous persons will run a utility. Aim is to add the absolute path of the utility the first time it runs so that next runs have the PATH in env & users can directly run... (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

8. Shell Programming and Scripting

Path a variable to sed that includes a path

Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example start="BEGIN /home/mavkoup/data" end="END" sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Discussion started by: mavkoup
4 Replies

9. Shell Programming and Scripting

File creating in another path.. application unable to locate

I am submitting a concurrent program (of HOST tyme) from Oracle apps screen, The MAIN shell program submits another program, (child) which is also a Shell program. The child writes data to log file. Now the main program, read the log and do some calculations and sends the data to user through... (1 Reply)
Discussion started by: Pradeep Garine
1 Replies

10. Shell Programming and Scripting

Readin document & creating path

Need a way to read a file in who every line is a path to a directory and make shortcut to that directory on a specific place. Example: line in the document /media/gogo/6651-FEAB/Desktop/ /media/gogo/6651-FEAB/Desktop/alex/ /media/gogo/6651-FEAB/linux/ ... (3 Replies)
Discussion started by: gogok_bg
3 Replies
asadmin-stop-appserv(1AS)					   User Commands					 asadmin-stop-appserv(1AS)

NAME
asadmin-stop-appserv, stop-appserv - stops the domains inthe specified directory SYNOPSIS
stop-appserv [--domaindir install_dir/domains] [--terse=false] [--echo=false] This command has been deprecated. Please use stop-domain to stop the domains in the specified or default domains directory. stop-appserv stops the domains in the specified or default domains directory. If the domains directory is not specified, the domains in the default domains directory are stopped. The default domains directory is install_dir/domains. This command can only be run locally. OPTIONS
--domaindir directory where the domains are stopped. If specified, path must be accessible in the filesystem. If not specified, the domain is stopped in the default install_dir/domains directory. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. Default is false. --echo setting to true will echo the command line statement on the standard output. Default is false. EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-domain(1AS), asadmin-start-domain(1AS), asadmin-stop-domain(1AS), asadmin-delete-domain(1AS), asadmin-list-domains(1AS) J2EE 1.4 SDK March 2004 asadmin-stop-appserv(1AS)
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy