?
Solved

bash scripting newbie

Posted on 2013-01-30
9
Medium Priority
?
160 Views
Last Modified: 2013-02-21
hi guys

I am new to bash shell scripting and have a few questions. I am from a java background.

Below is my customer.sh file which invokes the customer.jar
1.  I want to modify my customer.sh file so i do
$ vi customer.sh
but it does not allow me to modify(it is read only), any idea why?
How can i make it editable?

customer.sh

#!/bin/bash

export JAVA_HOME=/javaProj/jdk/1.6.0_22   
export PATH=$JAVA_HOME/bin:$PATH:$LD_LIBRARY_PATH   #  I am not sure what is $PATH:$LD_LIBRARY_PATH , any idea
export CLASSPATH=$CLASSPATH:$ROOT     #  I am not sure what is $CLASSPATH, any idea
export ROOT=/project/customer/customerAutomated

 touch $ROOT/customer.log   # does touch means it creates a file?
chmod 0777 $ROOT/customer.log

logAutos=$ROOT/autosys.log

emailFailFile=$ROOT/emailfail.txt

emailSubject="ERROR:- customer Status on `date`"

sendtotargetName="jacks@humpingtree.com"

echo " " ; echo "BEGIN TIME = `date`"

cd $ROOT

java -Dicg.env=prod  -jar $ROOT/customer.jar 123    # any idea what this means 'java -Dicg.env=prod'
sleep 2      # this makes the program sleep for 2 seconds, right ?

#***************************************************************************
echo "Checking Logs..."
#***************************************************************************
if ( grep "Problem occurred" $logAutos );
then
        echo "Alert: Problem occurred while updating customertables..."        
        echo "END TIME = `date`"
        exit 1
fi

echo "END TIME = `date`"
exit 0

Open in new window


Any help will be greatly appreciated
thanks
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 16

Assisted Solution

by:choward16980
choward16980 earned 200 total points
ID: 38837516
Push I to enable insert mode

push esc to exit insert mode

type :wq to write and quit.
0
 
LVL 26

Assisted Solution

by:pony10us
pony10us earned 900 total points
ID: 38837523
What are the permissions on the file?  

ls -l customer.sh

Please post the results.

Also, when in the file using vi you move the cursor to where you want to edit it and press the insert key to be able to edit. When complete you press the Esc key twice and the enter a colon and a "w" without the quotes to save the file.
0
 

Author Comment

by:royjayd
ID: 38837553
thanks , pressing the insert key works
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

Author Comment

by:royjayd
ID: 38837556
can you please help me with the questions i posted with in the script?

thanks
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 900 total points
ID: 38837559
What are the permissions on the file?
If
ls -l customer.sh
shows that you do not have write permission, and that you are the owner of the file, you can
chmod u+w customer.sh
If you are not the owner, then you may have to ask the owner to grant you permission.
0
 

Author Comment

by:royjayd
ID: 38837574
ls -l customer.sh

-rwxrwxrwx 1 customerproj customerproj 1745 Jan 30 18:07 customer.sh
0
 
LVL 26

Accepted Solution

by:
pony10us earned 900 total points
ID: 38837580
Line 4:     I am not sure what is $PATH:$LD_LIBRARY_PATH , any idea


3.3.1. LD_LIBRARY_PATH
You can temporarily substitute a different library for this particular execution. In Linux, the environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories; this is useful when debugging a new library or using a nonstandard library for special purposes. The environment variable LD_PRELOAD lists shared libraries with functions that override the standard set, just as /etc/ld.so.preload does. These are implemented by the loader /lib/ld-linux.so. I should note that, while LD_LIBRARY_PATH works on many Unix-like systems, it doesn't work on all; for example, this functionality is available on HP-UX but as the environment variable SHLIB_PATH, and on AIX this functionality is through the variable LIBPATH (with the same syntax, a colon-separated list).

LD_LIBRARY_PATH is handy for development and testing, but shouldn't be modified by an installation process for normal use by normal users; see ``Why LD_LIBRARY_PATH is Bad'' at http://www.visi.com/~barr/ldpath.html for an explanation of why. But it's still useful for development or testing, and for working around problems that can't be worked around otherwise. If you don't want to set the LD_LIBRARY_PATH environment variable, on Linux you can even invoke the program loader directly and pass it arguments. For example, the following will use the given PATH instead of the content of the environment variable LD_LIBRARY_PATH, and run the given executable:   /lib/ld-linux.so.2 --library-path PATH EXECUTABLE
 
Just executing ld-linux.so without arguments will give you more help on using this, but again, don't use this for normal use - these are all intended for debugging.

Line 5:        I am not sure what is $CLASSPATH, any idea

http://javarevisited.blogspot.com/2011/01/how-classpath-work-in-java.html

Line 8:        does touch means it creates a file?

Has much more capability than simply creating a file:  http://www.computerhope.com/unix/utouch.htm

Line 23:       any idea what this means 'java -Dicg.env=prod'

Truthfully I don't know java that well.

Line 24:        this makes the program sleep for 2 seconds, right

Yes
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 900 total points
ID: 38837624
man java
java(1)                                                                                                                                                  java(1)

NAME
       java - Java application launcher

SYNOPSIS
       java [ options ] class [ argument...  ]

       java [ options ] -jar file.jar
            [ argument...  ]
...
OPTIONS
       The launcher has a set of standard options that are supported on the current runtime environment and will be supported in future releases.  In  addition,
       the current impletmentations of the virtual machines support a set of non-standard options that are subject to change in future releases.

   Standard Options
...
       -Dproperty=value
              Sets a system property value.
0
 

Author Comment

by:royjayd
ID: 38839693
thanks guys

>> -Dproperty=value
              Sets a system property value.

Can you tell me where i can find it ? where can i see my system properties?
Can i do a search on my system properties

thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question