LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-09-2010, 08:02 AM   #1
waymanise
LQ Newbie
 
Registered: Aug 2010
Posts: 3

Rep: Reputation: 0
Post How to send '/' in expect?


Hi,

I'm trying to use expect to telnet to web server and send HTTP command like POST, GET, etc.

Here's my code

Code:
#!/usr/bin/expect -f

expect -c "
spawn telnet 192.168.1.1 80
send "POST /cgi-bin/auth HTTP/1.1"
exit 0
"
But this gives an error

couldn't read file "/cgi-bin/authgw-cgi": no such file or directory

I think this is because of /

How to send / in expect?

Thanks

Last edited by waymanise; 08-09-2010 at 08:04 AM.
 
Old 08-09-2010, 10:34 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
No that's not it. you're not writing the script right, and using double quotes for two different reasons, so it's just gibberish what you're writing.

Code:
#!/usr/bin/expect -f

spawn telnet 192.168.1.1 80
send "POST \/cgi-bin\/auth HTTP\/1.1/r"
exit 0
would by accurate, but I expect you'll need to set an expect after the send to process gracefully.

Last edited by acid_kewpie; 08-09-2010 at 10:36 AM.
 
Old 08-10-2010, 08:57 PM   #3
waymanise
LQ Newbie
 
Registered: Aug 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks a lot man. That should do it.
 
Old 08-18-2010, 08:18 AM   #4
waymanise
LQ Newbie
 
Registered: Aug 2010
Posts: 3

Original Poster
Rep: Reputation: 0
I finally get it to work using curl, very easy solution. Cheers
 
  


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
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
send: spawn id exp1025 not open in tcl/expect bharatbsharma Programming 3 04-22-2010 02:04 AM
Can't get expect to work. send will not display an output edomingox Linux - General 7 07-14-2009 12:04 AM
expect says it cant send the string to the spawned command exceed1 Programming 0 01-17-2009 06:51 AM
[Expect scripting] send problem ldp Programming 1 01-24-2005 02:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:02 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