LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   AIX (http://www.linuxquestions.org/questions/aix-43/)
-   -   y do i use bash command here ? (http://www.linuxquestions.org/questions/aix-43/y-do-i-use-bash-command-here-800780/)

shravee 04-08-2010 09:06 AM

y do i use bash command here ?
 
hi all,

I was doing a deployment of a .war file in AIX unix box.

after this, I am supposed to update a web.xml file in the .WAR file.

so i typed
jar -uvf wfr.WAR web.xml


but on entering the above command in the cmd promt , it did not work.
the err message what i received was " jar not found ".

INSTEAD WHEN I TYPED " bash " in command line and hit enter.

and again in the next line of command prompt when i executed the jar command . it functioned well..

so i want to know what was the function of bash. after which jar command executed.


also before using bash.. my command prompt appeared as " $ "

after entering bash my command prompt changed to my [ login /functional id enclosed in brackets.]

regards
shravan

pixellany 04-08-2010 09:12 AM

Moved to the AIX forum.

BASH is one of many shells used on Unix and Linux systems.

Just a guess: You were running some other shell and then switched to BASH. Presumably, the "jar" command works in BASH but not in your other shell.

AlucardZero 04-08-2010 09:50 AM

Quote:

but this command did not execute on the first go.
Be more specific.

shravee 04-09-2010 12:26 AM

hi AlucardZero, I have edited my post to make it more clear and understanding as u wished.
plz let me know if u know what is the reason behind it.

regards
shravan

catkin 04-09-2010 12:43 AM

It might help if you told us what actually happened when "it did not work".

shravee 04-09-2010 12:49 AM

Hi catkin, I have included the err message. it was " jar not found ".
but do let me know wats d gen purpose of typing " bash " in the cmd prompt.

regards
shravee

catkin 04-09-2010 01:12 AM

Quote:

Originally Posted by shravee (Post 3929444)
Hi catkin, I have included the err message. it was " jar not found ".
but do let me know wats d gen purpose of typing " bash " in the cmd prompt.

Oops! Sorry -- I missed that :redface:

When you type bash at the command prompt and press return, it starts a non-login interactive bash shell as a child of the current shell. The pstree command should illustrate that.

One possible explanation of why jar runs under the new shell but not under the old is that the PATH is different. echo $PATH should show that and should include jar's directory as shown by type jar.

shravee 04-09-2010 02:44 AM

hi catkin,

so can i take it granted that bash in general is used to create a new child shell under the same id.

regards
shravee

catkin 04-09-2010 03:20 AM

Quote:

Originally Posted by shravee (Post 3929521)
so can i take it granted that bash in general is used to create a new child shell under the same id.

That's not wrong but it is not the simplest and most comprehensive way of describing what happens when you run a command at the command prompt and what bash is.

When you enter a bash at the command prompt and press enter your current shell finds what bash is (you can do the same thing in a bash shell with type bash). In this case it finds it is /bin/bash. Your current shell then forks (produces an identical copy of itself with the single difference that the return code from fork lets the child process know it is the child). This being an identical process it is running as the same user (when you write id, I think you mean user). The child process, still running the same shell as your current shell, then calls exec which loads /bin/bash into the process (replacing your current shell in the child process with /bin/bash) and starts running it.

What bash does is described here. From your point of view the most important thing it does is (almost certainly) configure itself from ~/.bashrc and it is this file (or maybe another file that it references) that sets $PATH to a list which includes the jar program's directory.

There's no need to run bash to be able to run jar. You could configure your current shell's $PATH to include the jar program's directory. How to do that is dependent of which of several possible shells you are using. It is probably the one listed for your user in /etc/passwd.

Did you use pstree to see the relationship between your current shell and the bash shell you started from it?

shravee 04-09-2010 08:12 AM

Quote:

Originally Posted by catkin (Post 3929547)
Did you use pstree to see the relationship between your current shell and the bash shell you started from it?


no, I did not use the pstree to check the relationships. I will definitely do it when I work on similar kind of deployment. I cant check it now as its not possible. I will definitely share at that time with you.

regards
shravee


All times are GMT -5. The time now is 02:40 AM.