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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the exec: commanding a client to open

Status
Not open for further replies.

gjorgi

Programmer
Apr 4, 2005
12
0
0
US
Hello,
The command that I want to pass to the command prompt is:
smbclient //winComp/winShare -N
How to that with exec?
 
have you tried set cmdstr "smbclient //winComp/winShare -N"; exec $cmdstr?

_________________
Bob Rashkin
 
Have tried and got error message:
couldn't execute "smbclient /winComp/winShare -N": no such file or directory while executing "exec $cmdstr"
My samba is otherwise running as usual, normal file sharing and no reported problems when started "manually" (by typing that command at the prompt). I would like to automate it further.
I have also tried with
set cmdstr "smbclient ///winComp//winShare -N"
just in case the slashes are interpred in unexpected way but got the same message...
 
I guess if you type "smbclient //winComp/winShare -N" from a shell command prompt, you get the desired result, right?

Assuming that's so, what about:
set cmdstr {smbclient //winComp/winShare -N}; exec $cmdstr
or even
set cmdstr {smbclient "//winComp/winShare -N"}; exec $cmdstr

_________________
Bob Rashkin
 
That is correct, when I type the commad at the prompt I get the windows share from my Windoze machine. But when I try it with exec, it keeps giving me the error message about directory not existing.
Even with the suggested alternatives in wrapping the command before passing it to exec, I get the same result: an error message about directory not existing...
 

especially (from the 2nd):
exec and multiple command line arguments (took me weeks to find solution):

set cmd "/path/to/your/command.sh"
set my_arg_1 "first"
set my_arg_2 "second"

# solution:
set runcmd [list exec $cmd $my_arg_1 $my_arg_2]

if {[catch $runcmd res]} {
error "Failed to run command $runcmd: $res"
}

puts "result is: $res"

_________________
Bob Rashkin
 
In other words, make an executable script out of the command that is to be passed to exec and run it via exec...
All I got that way is an empty blinking cursor that doesn't accept anything as input and the only way out is Ctr-C...
But this may be a good nudge to the right direction...

#!/usr/bin/tclsh
set cmd "/root/sambaCommand.sh"
set arg1 "N"
set arg2 ""

set runCmd [list exec $cmd $arg1 $arg2]
if {[catch $runCmd res]}{error "Failed:$res}
puts "result: $res"

This is how I get empty prompt...
 
Sorry. I know exec can be tricky.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top