- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to send commands to some ports using scrip...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 04:19 AM
05-17-2005 04:19 AM
How to send commands to some ports using script?
I need to telnet to a Unix box using some ports. And send some commands.
Eg :
telnet
send ctrl+A
Now I will get a prompt.
Now send some commends.
send brk
send chkstatus
I tried using label . It didn't work.
e.g. : telnet 192.168.10.10 4006 <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 07:31 AM
05-17-2005 07:31 AM
Re: How to send commands to some ports using script?
perl -e 'print \cA' |nc
I can't remember if thats the right syntax for ctrl+A, you may have to change that to the decimal equivalent, I think its 001?
--Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:53 AM
05-17-2005 10:53 AM
Re: How to send commands to some ports using script?
To use a pipe and telnet, you have to force sleeps in to wait for the output, i.e.:
(
echo ^A
sleep 1
echo brk
sleep 1
echo chkstatus
sleep 1
) | telnet 192.168.10.10 4006
But the better option would be to use 'expect', if there is some sort of output expected after each command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 06:15 PM
05-17-2005 06:15 PM
Re: How to send commands to some ports using script?
'expect' is the right method to use for this.
check man expect to find out how to achieve this.
you can also do through pipe like this,
mkfifo pipe # this will create the pipe
cat > pipe # this will open the pipe and wait for input, then go to another session
telnet host < pipe # this will open telnet session with input from pipe
now whatever sent in pipe will be piped to telnet. you can use this method to control it from script.
Regards,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2005 06:04 AM
05-18-2005 06:04 AM
Re: How to send commands to some ports using script?
printf \\001\\nbrk\\nchkstatus|nc 192.168.10.10 4006
the nice thing about netcat is you don't have to wait for responses, that is built in to the program.
check out the man page for more info:
man nc
--Dave