Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting and stoping network in slackware using tcl/tk

Status
Not open for further replies.

Linuxhaxz

Programmer
Nov 20, 2006
2
GB
Hi there, this is my first post, so please be nice...

I have modified a small tcl/tk script to stop and start the network on my Slackware box (Slack 11, 2.6.18 kernel) but only the stop function works, not the start and im not sure if its a programming error or something else.

Any help would be greatly appreciated

Code:
#!/usr/bin/env wish
set netcommand "/etc/rc.d/rc.inet1";
global netcommand;
proc netstart {} {
global netcommand
exec $netcommand start &;
}
proc netstop {} {
global netcommand;
exec $netcommand stop &;
}
proc launchbrowser {} { exec firefox &;}
proc launcheditor {} { exec pico &; }
frame .app -borderwidth 10;
.app configure -background lightblue;
pack .app;
button .app.ssh-go -text "Start Net" -command netstart;
button .app.ssh-end -text "Stop Net" -command netstop;
button .app.browser -text "Web Browser" -command launchbrowser;
button .app.launcheditor -text "Text Editor" -command launcheditor;
.app.ssh-go configure -foreground green;
.app.ssh-end configure -foreground red;
pack .app.ssh-go .app.ssh-end .app.browser .app.launcheditor;
 
I wonder if you're not waiting long enough for the start command to execute. Suppose you don't run netstart in the background. Also, see what the exec returns:
Code:
proc netstart {} {
  global netcommand
  set rcode [exec $netcommand start]
}

Also, although it doesn't change anything, any variables in the main script are, by definition, in the global scope. You only need the global declaration in the proc's.

_________________
Bob Rashkin
 
well, i got it going, turns ou you need a different command to start the net!

Bong, changing the script as you suggested puts all the outputs into the error box, and i would like to keep it in the terminal, thanks anyway

Code:
#!/usr/bin/env wish
set netcommand "/etc/rc.d/rc.inet1";
global netcommand;
proc netstart {} {
exec /sbin/dhcpcd -d -t 10 eth0;
}
proc netstop {} {
global netcommand;
exec $netcommand stop &;
}
proc launchbrowser {} { exec firefox &;}
proc launcheditor {} { exec pico &; }
frame .app -borderwidth 10;
.app configure -background lightblue;
pack .app;
button .app.net-go -text "Start Net" -command netstart;
button .app.net-end -text "Stop Net" -command netstop;
button .app.browser -text "Web Browser" -command launchbrowser;
button .app.launcheditor -text "Text Editor" -command launcheditor;
.app.net-go configure -foreground green;
.app.net-end configure -foreground red;
pack .app.net-go .app.net-end .app.browser .app.launcheditor;

just incase anyone needs it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top