running commands from outside of bash

Hello all!

I have two consoles.I know the PID of these two.Now I want to execute a command in console#1 but from console#2. How can I achieve this?
Anyone can do something for my query?

Click here if you can't understand my query or to know the need for this query.

Have you looked into using screen for this?

man screen

on console #1, type screen, load an app, whichever you want. Then press Ctrl-A and hit the d key.
this will detach you from the screen, placing you back on the console.

type screen -list, to see the detached screens. you can have many, note the number.
type screen -R <screen number> to reattach.

can name the screens, send commands, and more.

Now, once the screen is detached, you can ssh into the the box running console 1 (with screen), from console 2, and load that screen onto console 2. Picking right up where you left off at.

Thanks a lot LOCUSTFURNACE!
I didn't know this 'screen' before.
I daresay this will keep me busy for some days..
I am still working with the man page of this screen command.But the
problem couldn't be solved by me yet.
The thing is I want to prepare a shell script which will first login to
another system and execute some commands in that system.All by
the script itself.Another thing is when I execute
"screen -S session_name ssh somebody@dexter" screen creates a
session called "session_name" and executes 'ssh somebody@dexter'
command so I am asked to give the password of user "somebody" at a
machine called "dexter".After supplying the password again a bash is
forked by this ssh command from "session_name"bash created by Screen.
And I do " ^C-Ad " to detach this "session_name". Then I execute
"screen -S sessin_name -X pwd". But when I reattached that session and
looked there ,that pwd hasn't been executed there.(man page says that for
password protected sessions -X option won't work.)

I think my command is being executed in 

"session_name" bash and not in the bash created by "ssh" command or
something like that.

I tried "screen {ssh somebody@dexter;pwd}" thinking that both will be
executed in the new window that is going to be created by screen.Stupid
thing..It's a syntax error,I suppose. Is there any way to give two
commands on the command line?.

Even in that case also pwd will be executed in the bash created by
screen and not in the bash created by the previous command "ssh".I
couldn't comfortably tackle this problem.I AM COMPLETELY AT SEA.

Hi, did you solve the problem?

Thanks

Marco