?
Solved

Why Can't I run my Unix Scripts and Programs?

Posted on 2011-10-18
13
Medium Priority
?
603 Views
Last Modified: 2012-05-12
We have a new AIX server that has been provided. I am setting up the software. WE use JD Edwards EnterpriseOne 8.11 Software.

I have copied the files/folders from our existing server to this new one. However, when I try to run any of the scripts or programs I get a message saing "not found". But I can see the scripts in the list. Also I  made sure I sudo as the owner of the files (psft811) but I still cant run or even get the system to see them. I did a ls -al and it clearly shows psft811 as the owner and that is the user I did a sudo su - psft811 with success.

What am I missing? See screen prints for details.  screen print2 screen print1
0
Comment
Question by:matrix0511
  • 6
  • 6
13 Comments
 

Author Comment

by:matrix0511
ID: 36990518
As a way to try and test I tried to run the script "rmics.sh" which is shown above. if you look at the first screen print you can see the "rmics.sh" script shows in the list with the owner being that psft811 user.  But I still can't run it or it says not found.
0
 
LVL 10

Accepted Solution

by:
Murugesan Nagarajan earned 2000 total points
ID: 36990578
That is because of the environment variable "PATH"

You can execute any of the following
1.
cd /apps/PeopleSoft/E811/system/bin32
export PATH=".:$PATH"
rmics.sh

Open in new window


2.
cd /apps/PeopleSoft/E811/system/bin32
./rmics.sh

Open in new window


3.
export PATH="/apps/PeopleSoft/E811/system/bin32:$PATH"
rmics.sh

Open in new window

0
 
LVL 47

Expert Comment

by:David
ID: 36990643
try ./scriptname    rather than just entering scriptname   your current directory is not part of your path.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 10

Expert Comment

by:Murugesan Nagarajan
ID: 36990746
Usage of "./" is dependent on the usage of the command where you are using rmics.sh

Example Code:
cat /home/sadhana/.Murugesan/ee/rmics.sh
#/bin/ksh
export PATHwithDot=".:$PATH"
export PATH=`echo $PATH | sed 's/:\.\/://g;s/^\.://g;s/:\.$//g;'`
echo "As of now PATH does not have ."
echo "value of \$PATH"
echo $PATH
export PATHWithoutDot="$PATH"
find $PWD/a -type d  -exec ls -ld {} \;
echo "output of the command using rmics.sh will be      rmics.sh: command not found"
rmics.sh
echo "This can be resolve using one of the following ways:"
echo "way1:"
export PATH="$PATHwithDot"
echo "now the output of rmics.sh"
rmics.sh
echo "way2:"
export PATH="$PATHWithoutDot"
echo "now the output of ./rmics.sh"
./rmics.sh
echo "way3:"
export PATH="$PATHWithoutDot"
echo "now the output of rmics.sh"
/home/sadhana/.Murugesan/ee/rmics.sh

Open in new window


cat rmics.sh
#!/bin/ksh
echo The name of this script is $0

Open in new window

0
 

Author Comment

by:matrix0511
ID: 36990773
Guys, I"m not a Unix expert so bare with me on this. But you are basically saying it's because the environment variables are not setup propery?

@murugesandins, can you explain how those commands allow me to use those scripts/programs?

And how can I set this up so that I don't have to manually enter all those commands each time I need to execute a script or program? I'm sure I will need to update my.profile? If so, what specific commands or path info do I need to update it with?

Thanks.
0
 

Author Comment

by:matrix0511
ID: 36990784
I think I just need a quick and dirty education in how the PATH/Environment variables work on Unix. I never quite understood it.

I come from a Windows background so I need more explanation on how it all works.

Thanks in advance.
0
 

Author Comment

by:matrix0511
ID: 36990799
Here is what my .PROFILE looks like. I'm sure I need to update this with PATH info. I just have no idea what to add to address this. profile.txt
0
 
LVL 10

Expert Comment

by:Murugesan Nagarajan
ID: 36990892
The PATH environment variable will be used to look into the command which you are executing.
For example:

$ export PATH="/home/poornima/.Murugesan:$PATH"
$ ls -l /home/poornima/.Murugesan/m1.sh /home/poornima/m1.sh
-rwxr--r--    1 poornima poornima       54 Oct 19 11:35 /home/poornima/.Murugesan/m1.sh
-rwxr--r--    1 poornima poornima       65 Oct 19 11:36 /home/poornima/m1.sh
$ m1.sh
this file is in the directory /home/poornima/.Murugesan


[code]
$ export PATH="/home/poornima/:$PATH"
$ m1.sh
this file is in the directory /home/poornima/

Open in new window




Assume there are 2 (script) developers who are creating "m1.sh"  in the following directories
      /home/poornima/m1.sh
      /home/poornima/.Murugesan/m1.sh
In this case the .profile should not be edited for updating PATH environment variable.
Those two users update their PATH environemt variable in their own terminal after logon.

Assume that there are 5  (script) developers  who are using all the scripts under the directory "/home/poornima/allScripts/" then .profile needs to be updated with PATH to contain the PATH environment variable.
0
 
LVL 10

Expert Comment

by:Murugesan Nagarajan
ID: 36990906
in the given .profile file
PATH contains the directories in the following sequence:
        /usr/bin
        /etc
        /usr/sbin
        /usr/ucb
        $HOME/bin
        /usr/bin/X11
        /sbin
        .

Hence the commands which are executed by all the users will be searched in the above mentioned directories in sequences.
0
 
LVL 10

Expert Comment

by:Murugesan Nagarajan
ID: 36990912
Url for Setting Environment Variables
https://www.ccs.uky.edu/docs/cluster/env.html
0
 

Author Comment

by:matrix0511
ID: 36990965
I apologize guys. But I'm still having trouble understanding this. Do I have to define a path to every directory I want to access in order for unix to allow me to run scrlipts/programs in those dirs?

That seems odd to me. and what does it mean when it states: "EXPORT PATH"?

This software I have setup (JD Edwards) is software that will be used by all users, so I don't want to have to issue PATH commands each time I need to run a program. Man, sorry, I'm just totally confused when it comes to understanding how these environment variables work.

I know with Windows, most of the Software that is setup or insalled...the install paths are defined in the Environment Variables setup. But looks like Unix is totally different.
0
 

Author Comment

by:matrix0511
ID: 36990971
maybe I should ask it like this. What PATHS should I have defined in my .profile in order to do what I'm trying to do?
0
 
LVL 10

Expert Comment

by:Murugesan Nagarajan
ID: 36991373
As I told earlier
You can add the following in .profile
export PATH="/apps/PeopleSoft/E811/system/bin32:$PATH"

Open in new window

so that you(and everyone who logon to that account) can execute rmics.sh from any directory


or:
You can add the following in .profile
export PATH=".:$PATH"

Open in new window

so that you(and everyone who logon to that account) can execute rmics.sh using the following
cd /apps/PeopleSoft/E811/system/bin32
rmics.sh

Open in new window



or:
without adding anything in the file .profile
so that you(and everyone who logon to that account) can execute rmics.sh using the following
cd /apps/PeopleSoft/E811/system/bin32
./rmics.sh

Open in new window

0

Featured Post

What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 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