LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-15-2012, 07:26 AM   #1
kamesp
LQ Newbie
 
Registered: Jun 2012
Posts: 10

Rep: Reputation: Disabled
Executing tcl script by logging to a linux machine is there any way other than expect


Hi all,

I have a requirement where in i need to execute a script using tcl. The script will be executed from a linux or solari box logging to another linux machine for whch i will be using spawn <ip address>

#!/home/pub/bin/expect
spawn telnet 172.16.69.34 23
expect "login name:"
send "administrator\r"
expect "password:"
send "Administrator1@\r"
expect "Windows NT Domain:"
send "\r"
expect "C:\WINNT\Profiles\Administrator>"
send "\r"
expect "C:\WINNT\Profiles\Administrator>"
send "cd ../../../\r"
expect "c:\>"
send "cd program files/ap/osu/bin\r"
expect "C:\PROGRAM FILES\AP\OSU\bin>"
send "osumgr -j ExportSiteParams -a run -d\r"
expect {
-re ".*Generic Error.*" {puts "Success

Here initially i amusing "#!/home/pub/bin/expect" but through the script i need to expect something for which i am not able to use tcl languae flexibly like open file and match some patter etc.

Is there any other easier way to connect to the linux machine without expect like the heaer should be #!/home/bin/tclsh so that i can use all tcl commands flexible.

Thanks in advance...

Please help me in proceeding further......
 
Old 06-15-2012, 08:02 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Your question is a little unclear, as you mention connecting from a *NIX box to a Linux box, but the code you included seems to be trying to telnet to a Windows box?

If both sides are indeed *NIX boxes, I'd suggest you use SSH rather than TELNET to connect, and you set up pre-shared keys, so you can log in without a password. After doing that, you can easily run a TCL script on the target machine.

If the target is a Windows box, you should be able to achieve the same, except that you need to set up an SSH server first. Look at http://www.cygwin.com/ and http://sourceforge.net/projects/sshwindows/ for this.
 
Old 06-15-2012, 11:44 AM   #3
kamesp
LQ Newbie
 
Registered: Jun 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks for the update... Sorry for confusion...

Yes i have scenarios where i can run the scripts from Linux to Linux and Linux to windows.

Let us say i have a sample script ..

connect to linux or windows machine
set a 5
puts $a

This i want to execute from a linux machine where it should connect to another linux or windows machine and get executed there where in the above code first step would be connecting to the machine and then the next two lines of code..

What is the code to connect to the linux or windows machine ? Hope it is claer now.. Can you give me the sample code here...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid command type "llType" error occuring when executing a tcl script in ns2.34 madhu.bm Linux - Software 1 05-04-2012 05:30 AM
Expect/TCL Logging -- any way to create a clean log file? keller999 Programming 1 04-18-2011 12:27 PM
Telnet script on Unix machine without expect cristoph_ Programming 7 12-24-2008 10:23 AM
executing a script when logging via ssh rubby1 Linux - General 8 10-06-2005 03:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration