LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cannot execute script file from shell (https://www.linuxquestions.org/questions/linux-general-1/cannot-execute-script-file-from-shell-78361/)

shahrahulb 08-02-2003 02:01 PM

cannot execute script file from shell
 
I have redhat 9.0 linux

Say i have a created small script file:
$cat > temp
pwd
ls

then i made it executable by $chmod +x temp

now if try to execute the file, i get
$temp
bash: temp command not not found.

How can i run the temp file?

also i have installed jdk1.4.0_04.
every time i reboot my system, ihave to export the path as :
export PATH=/usr/java/jd..../bin:$PATH

is there a way to sotre the PATH in some file so that i don't have to export everytime I login.

when i used to work in school, i had save the PATH in
cat $HOME/.profile.

but i am not able to open $HOME/.profile in my home computer with Redhat 9.0.

Your suggestion is highly appreciated.

Thank you very much.

Rahul.

david_ross 08-02-2003 02:29 PM

Try:
./temp

lfur 08-02-2003 02:30 PM

shahrahulb,

I am assuming that you are using BASH shell. To determine this enter:
echo $SHELL

and it will print out the name of your shell.

1.) You have to add:
#!/bin/bash

at the start of the script. You can determine where you bash is with:
whereis bash

If you are using another shell, like csh or ksh, you have to change that ( #!/bin/ksh for example).

2.) You can create a file called .bash_login in your home directory and add:
export PATH=$PATH:/what/ever

Enjoy

david_ross 08-02-2003 02:31 PM

As for the path - try puting it in:
~/.bash_profile

potraike 03-04-2008 07:02 AM

script executed inside another script dont make changes
 
Hello,

I have a script B that is executed inside a main script A. The script B make some changes in the environment variables like JAVA_HOME.
When I execute script B in command line everything's fine and the variables are updated.
When I execute script A, apparently the script B outputs the right things but the variables are not updated at the end. I've tried all the ways:

./scriptB.sh
. scriptB.sh
path/to/script/scriptB

please help me!!!!!


All times are GMT -5. The time now is 06:09 PM.