INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Problem calling dos color command from tcl

Problem calling dos color command from tcl

(OP)
I'm trying to change the font color of the command prompt by executing "color 09" from a tcl script. I got an error so I tried executing the command in a bat file. I make the call:

catch [ exec ChangeColor.bat "0A" ]

ChangeColor.bat is just:
color %1

This doesn't work though.

 

RE: Problem calling dos color command from tcl

This works
sys.tcl

CODE

set cmd "|mycmd.bat"
set f [open $cmd "r"]
close $f
where
mycmd.bat is:

CODE

start color 0A
But it doesn't change the font color in the recent command window, insted it opens new command window (with green on black).


 

RE: Problem calling dos color command from tcl

(OP)
I'm trying to change the color of the recent window. I tried using your solution and taking out the start from the bat file, but that wont work. Do you know why?  

RE: Problem calling dos color command from tcl

I'm on windows Vista and that works.
Have you exactly copied the code I posted above? For example if you forget the pipe character "|" in

CODE

set cmd "|mycmd.bat"
then it will not work.
 

RE: Problem calling dos color command from tcl

This works too

CODE

set cmd "mycmd.bat"
exec $cmd
or this

CODE

exec cmd /c start color 0A
But both of the above scripts opens new colored window, because they used the START command. Without START command it doesn't work.

I tried to execute this command in another languages too:
Perl

CODE

use strict;
use warnings;

my $rc=system("color 0A");
print "\$rc = $rc\n"

Python

CODE

import os

rc=os.system("color 0A")
print "rc = %d" % rc

REXX

CODE

md = "color 0A"
cmd
say "rc = " || rc

All the above code examples in Perl, Python, REXX (ooRexx and Regina) work in windows without problems and (in difference to Tcl) they colors font in the current window.

It seems to be somethng wrong with Tcl on windows (I'm using ActiveTcl) - I don' know what's wrong, but if I would you I would rather use other language for the given purpose on windows.
 

RE: Problem calling dos color command from tcl

(OP)
Thanks for the help. I'd switch but I'm already to invested in the tcl script I have now. Thanks again though.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close