LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   SSH remote to local chat (https://www.linuxquestions.org/questions/programming-9/ssh-remote-to-local-chat-844243/)

mellor 11-14-2010 05:00 PM

SSH remote to local chat
 
May be no one else needs something like this...

I have the need to SSH into a Slackware 12 box to provide remote support.
I got this, but it doesn't provide for a real 2-way communication.

while : ;
do read -p "Enter text to Local: " TXT ;
DISPLAY=:0 Kdialog --inputbox "$TXT" ;
done

So this loops and all, but it doesn't have a history and I have to wait for a return from the Local operator. If the operator has changed focus I can be waiting all day for a response and I would have to start another session to post a second comment.

What is nice is that it's small and I can create the .sh when I remote in.

-----Update since I started

I now have two scripts to take over from the first one. I have to have 4 SSH running to get this to work.

1 SSH to move(archive) and create a chat.txt; it also fires off a .sh that fires off a console that tails a chat.txt so the operator can see the chat history
2nd SSH to fire off a .sh that loops a Local kdialog input box that appends the chat.txt
3rd SSH to tail -f the chat.txt file on the remote so I can see the chat history
4th SSH to loop a read -p on the SSH so I can append the chat.txt

Is there a better way?
Or an open source that will let me have coms without the server overhead?

ortho-orange#42 11-14-2010 06:04 PM

There are a few commands you might want to look at: "write" and "talk". "write" worked like a charm ssh'd into a Slackware VM as two different users. I didn't get a good response from "talk" but it looks like it should do the same thing...

mellor 11-14-2010 06:53 PM

Our product is not very flexible as far as user are concerned....

... Here is where I'm going to get flambeed, but it's not my product...
Everyone logs in as root.

The next release users will not log in as root, but everyone is still going to log in as the same user.
I think this is going to be a limiting factor as far as using a user name to chat with someone.

ortho-orange#42 11-14-2010 07:03 PM

That is nasty, but I'll leave the flaming for someone else :)

Actually, with those apps I mentioned, you can specify a tty, or pseudo-terminal, so if you can get that from whoever's on the other end (perhaps programatically), it should work the same as with a username.

mellor 11-14-2010 09:01 PM

That write command works great, except for the fact that on the local computer it opens a terminal that will only receive text.
It is not editable on the Local side. I would have to get him to open a terminal on his side so we can chat.
I can open a terminal for him on SSH but since I opened it I get the response back to myself.

I really don't want to take control of the gui via VNC to open a terminal.

It is easier than what I currently got except that I can do what I currently got from the SSH terminal session without grabbing the GUI.
Now I just have to find out how to change what gets opened by the write command or how to open a shell for the client that isn't link back to the remote

ortho-orange#42 11-14-2010 09:57 PM

Hmm, you're right about "write", "talk" may be more useful in that regard.

I started looking at your script, which is a neat little bit of code, btw, and added a little to it:

Code:

HIST="";

while : ;
do read -p "enter..: " TXT ;
if [ "$TXT" = "hist" ]; then
        echo -e "History: $HIST"
else
IV=`DISPLAY=:0 kdialog --inputbox "$TXT"` ;
HIST="$HIST\r\n$TXT\r\n$IV";
if [ "$IV" = "hist" ]; then
        DISPLAY=:0 kdialog --msgbox "$HIST" ;
        IV=`DISPLAY=:0 kdialog --inputbox "$TXT"` ;
fi
echo "return: $IV";
fi
done

This is a super ugly 10 minute job, but it just maintains a history itself, and whenever someone types "hist" it spits it out. Formatting is messed up in the kdialog history, maybe there's a better way to do that. Plus, the only time the local user can see their history is after you've sent your text. This also doesn't write anything to a file, but that should be as easy as a redirected echo.

Anyway, maybe with all this activity someone who knows more will come along & have some clues. Good luck, and if I think of anything else I'll post it :)


All times are GMT -5. The time now is 12:40 PM.