This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

TCL wont display anything after a space from shell script ou

Old posts that have not been replied to for several years.
Locked
D
Dragon-Tzu

Post by Dragon-Tzu »

Hi, im trying to write a basic script to echo the output of a shell script to a channel on the !stat command.

The shell script extracts certain information from the computer and echo's the result, for example

sysType=`uname`
echo "[System : $sysType]"

This gives the following output to the console
System : Linux

( there are other lines like for cpu and process info as well)

In the tcl i have got the code

proc displayStats {chan args} {
set stat[open "|/home/toby/eggdrop/scripts/stat.sh" r]
while {![eof $stat]} {
catch {set result [gets $stat]}
puthelp "PRIVMSG $chan $result"
}
catch {close $stat}
}

Which goes down the lines writing them to the channel.

THE PROBLEM IS:

When it outputs it to the channel it stops as soon as it hits a space. For example :

<bot> [System

where it should be

<bot> [System : Linux]

Im using the tcl-8.3.3-65 and eggdrop version eggdrop v1.6.10 on a redhat 7.2 system with 2.4.7-10 kernel

Any help would be much appreciated, im on icq 50572181 if anyone wants to ask me about it.

Thanks in advance guys, Dragz




<font size=-1>[ This Message was edited by: Dragon-Tzu on 2002-05-20 09:24 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This is because of the puthelp command you have used.

On IRC, you can only sent 1 non-breaking string (AKA, 1 word) to the server, unless you sent a : before the string.

Try using

puthelp "PRIVMSG $chan :${result}"
t
tainted
Master
Posts: 239
Joined: Sun May 12, 2002 8:00 pm
Location: chicago
Contact:

Post by tainted »

Could also just drop that shell script and have this in your proc:

putserv "PRIVMSG $chan : System: [exec uname]"


<font size=-1>[ This Message was edited by: tainted on 2002-05-22 15:58 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This may cause problems if the script returns more than one line, as the queue will have a load of dribble inserted into it (remember you can only sent a newline to a server, when you have finished a command, not when you want to drop to a new line)
D
Dragon-Tzu

Post by Dragon-Tzu »

Ok well adding the : worked well, thanks loads, i cant believe i missed it.

Ive decided to put it all in one tcl, using the command shown above.

the problem ive now come against is
using
[exec cat /proc/cpuinfo|grep '^model name']

doesnt seem to work.

do i need to add " " around certain parts of it?

Thanks for replying guys, much appreciated

<font size=-1>[ This Message was edited by: Dragon-Tzu on 2002-05-23 15:14 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The pipe operator "|" is something interpreted by the shell you're using, not the operating system. So you can't use that with exec. Grep is easy to simulate in tcl, just use regexp and print the line if it matches.
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

yes, pipes are a function of a shell, but there's nothing stopping ya executing a shell to run it it :razz:
for example:
exec sh -c {ls |grep blah}
t
tainted
Master
Posts: 239
Joined: Sun May 12, 2002 8:00 pm
Location: chicago
Contact:

Post by tainted »

Bingo.
Locked