Sponsored Content
Full Discussion: How to Parse a Prompt?
Top Forums Shell Programming and Scripting How to Parse a Prompt? Post 302376731 by april on Wednesday 2nd of December 2009 06:16:24 AM
Old 12-02-2009
How to Parse a Prompt?

On the command, when I type in certain commands, they will display a prompt waiting for some input. When I type in the requested input, it will display the info I requested.

For example, if I enter the telnet command, it will display a telnet prompt and wait for me to enter something.

I wonder in my script if I can parse the command line to see if a prompt is popped up. If it is, then supply the requested info that is stored in a file.

OS is Solaris 2.8 and running ksh.

Please help. Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

prompt

how do we change the command prompt? right now my prompt says felix% where felix is the machine i´m on. but how do we change it? for example, how can i make it say me% and how do we get it to tell us what directory we are under because when i change into a subdir then the prompt... (1 Reply)
Discussion started by: eeldivady
1 Replies

2. UNIX for Dummies Questions & Answers

prompt why ?

Even though I give rm -f *, the files are listed for confirmation of removal . Why ? Thanks LS (2 Replies)
Discussion started by: ls1429
2 Replies

3. Solaris

Can't get ok prompt

Hi, I'm attempting to reinstall a damaged installation of Solaris 9 (on a SunFire). Connected via serial from a PC. Can't get to the "ok" prompt to launch install from CD. Ctrl+break acknowledges my request for a break, but no prompt. "#." gets me an "sc>" prompt, with several options, but... (3 Replies)
Discussion started by: shonenfan
3 Replies

4. UNIX for Dummies Questions & Answers

CWD as Prompt

I need a one line command called cd (must also still function as cd) and will allow the prompt to change to the cwd. All I can figure out is to change the .cshrc but there must be an easier way in a one line command no? (1 Reply)
Discussion started by: petter_uk
1 Replies

5. Solaris

OK prompt

Here is a silly question: I have a Sun 220R and I need to get to the OK prompt. I can't hook up a monitor and keyboard to it. Its on a KVM right now and I also have a console connected to it. I can use PuTTY to get to the console and then connect to the 220R from there. How can I get to the... (3 Replies)
Discussion started by: hshapiro
3 Replies

6. Shell Programming and Scripting

How to a prompt a particular value???

Hi i am working with clearcase in my UNIX machine... Accidentally some had ran a script to check out all files in the machine.... Now i am actually trying to uncheck out all those files and had written a script for it.... The problem is that when ever i am trying to uncheck out the files, its... (2 Replies)
Discussion started by: grajesh_955
2 Replies

7. Solaris

ok prompt

There is a number before the ok prompt in OBP between brackets {}. It is 0 most of the time but sometimes it is different number {9} ok or {0} ok What does this number mean and how it gets changed? (3 Replies)
Discussion started by: StarSol
3 Replies

8. Solaris

No prompt!

We have a Solaris 10 machine. Today a weird issue happened. After login remotely via ssh, the motd appeared BUT there was no prompt! The prompt only appears after pressing Ctrl+d or Ctrl+c. Strange behaviour. I have checked /etc/profile and own user .profile, there is no anamoly. ... (11 Replies)
Discussion started by: sundar63
11 Replies

9. UNIX for Dummies Questions & Answers

How to Change the % prompt to - prompt in UNIX?

how to Change the % prompt to - prompt in unix :wall: ---------- Post updated at 07:40 AM ---------- Previous update was at 07:38 AM ---------- How To display the last modification time of any file in unix ---------- Post updated at 07:40 AM ---------- Previous update was at 07:40 AM... (2 Replies)
Discussion started by: manjiri sawant
2 Replies

10. Solaris

Unable to move from rsc prompt to ok prompt

Hi, on sunfire v890 unable to move from rsc prompt to ok prompt, i have executed the command break. (9 Replies)
Discussion started by: manoj.solaris
9 Replies
telnet(1c)																telnet(1c)

Name
       telnet - user interface to the TELNET protocol

Syntax
       telnet [host[port]]

Description
       The interface is used to communicate with another host using the TELNET protocol.  If is invoked without arguments, it enters command mode,
       which is indicated by the prompt, telnet>.  In this mode, accepts and executes the commands listed below.  If it is invoked with arguments,
       it performs an open command (see below) with those arguments.

       Once a connection is opened, enters input mode.	The input mode is either character-at-a-time or line-by-line, depending on what the remote
       system supports.  In character-at-a-time mode, text is sent to the remote host as it is	typed.	 In  line-by-line  mode,  text	is  echoed
       locally	and  only  completed lines are sent to the remote host.  The local-echo-character, initially ^E.  turns the local echo on and off,
       which is useful when you want to enter passwords without them echoing to the screen.

       In either mode, if the localchars toggle is TRUE (the default in line mode), then the user's quit, intr, and flush characters  are  trapped
       locally	and  sent  as  TELNET protocol sequences to the remote side.  Options such as toggle autoflush and toggle autosynch flush previous
       terminal input, as in quit and intr, in addition to flushing subsequent output to the terminal until the remote host acknowledges the  TEL-
       NET sequence.

       To  issue  commands when in input mode, precede them with the escape character, initially the control character followed by a right bracket
       (^]).  When in command mode, use the normal terminal editing conventions.

       The following commands are available:

       open host [ port ]
		      Opens a connection to the named host.  If no port number is specified, attempts to contact a TELNET server  at  the  default
		      port.   The  host specification may be either a host name or an Internet address specified in the dot notation.  For further
		      information, see and

       close	      Closes a TELNET session and returns to command mode.

       quit	      Closes any open TELNET session and exits

       z	      Suspends This command only works when the user is using the

       mode type      The type is either line, for line-by-line mode, or character, for character-at-a-time mode.  The local host asks the  remote
		      host for permission to go into one or the other mode.  The remote host enters the requested mode if it is capable of it.

       status	      Shows the current status of This includes the peer one is connected to, as well as the state of debugging.

       display [ argument... ]
		      Displays all, or some, of the set and toggle values (see below).

       ? [ command ]
		      Accesses	on-line  help.	 With no arguments, prints a help summary.  If a command is specified, prints the help information
		      for that command.

       send argument(s)
		      Sends one or more special character sequences to the remote host.  One or more of the following arguments can be specified:

		      escape
			     Sends the current escape character (initially the control character followed by a right bracket, ^]).

		      synch
			     Sends the TELNET SYNCH sequence.  This sequence causes the remote system to discard input that was previously entered
			     but  that	it  has not yet read.  This sequence is sent as TCP urgent data and may not work if the remote system is a
			     4.2 BSD system.  If it does not work, a lower case r may be echoed on the terminal screen.

		      brk
			     Sends the TELNET BRK (Break) sequence, which may have significance to the remote system.

		      ip
			     Sends the TELNET IP (Interrupt Process) sequence, which causes the remote	system	to  abort  the	currently  running
			     process.

		      ao
			     Sends  the TELNET AO (Abort Output) sequence, which causes the remote system to flush all output from the remote sys-
			     tem to the user's terminal.

		      ayt
			     Sends the TELNET AYT (Are You There) sequence.  The remote system may or may not respond.

		      ec
			     Sends the TELNET EC (Erase Character) sequence, which causes the remote system to erase the last character entered.

		      el
			     Sends the TELNET EL (Erase Line) sequence, which causes the remote system to erase the line currently being entered.

		      ga
			     Sends the TELNET GA (Go Ahead) sequence.  Often this sequence has no significance to the remote system.

		      nop
			     Sends the TELNET NOP (No OPeration) sequence.

		      ?
			     Prints out help information for the send command.

       set argument value
		      Sets a variable to a specific value.  The off value turns off the function associated with the variable.	The current values
		      of variables can be displayed with the display command.

       The following variables that can be specified:

	      echo
		     Toggles between local echoing of entered characters, and suppressing echoing of entered characters when in line-by-line mode.
		     The value	is initially ^E.

	      escape
		     Enters the command mode when you are connected to a remote system.  The value is initially the control character followed	by
		     a left bracket (^[).

	      interrupt
		     Sends  a TELNET IP sequence (see send ip above) to the remote host if is in localchars mode (see toggle localchars below) and
		     the interrupt character is typed.	The initial value for the interrupt character is the terminal's intr character.

	      quit
		     Sends a TELNET BRK sequence (see send brk above) to the remote host if is in localchars mode (see	toggle	localchars  below)
		     and the quit character is typed.  The initial value for the quit character is the terminal's quit character.

	      flushoutput
		     Sends  a  TELNET  AO  sequence  (see send ao above) to the remote host if telnet is in localchars mode (see toggle localchars
		     below) and the flushoutput character is typed.  The initial value for the flush character is the terminal's flush character.

	      erase
		     Sends a TELNET EC sequence (see send ec above) to the remote system if telnet is in localchars mode  (see	toggle	localchars
		     below),  and  if  telnet is operating in character-at-time mode.  The initial value for the erase character is the terminal's
		     erase character.

	      kill
		     Sends a TELNET EL sequence (see send el above) to the remote system if is in localchars mode (see	toggle	localchars  below)
		     and if is operating in character-at-a-time mode.  The initial value for the kill character is the terminal's kill character.

	      eof
		     Sends  this  character  to  the remote system if is operating in line-by-line mode and this character is entered as the first
		     character on a line.  The initial value of the eof character is the terminal's eof character.

       toggle arguments...
	      Toggles (between TRUE and FALSE) flags that control how responds to events.  More than one argument may be specified and the current
	      value of these flags can be displayed with the display command.  Valid arguments for the command are the following:

	      localchars
		     Causes  the flush, interrupt, quit, erase, and kill characters to be recognized locally and transformed into appropriate TEL-
		     NET control sequences if this flag is set to TRUE.  (See set above).  The appropriate TELNET control sequences are:  ao,  ip,
		     brk,  ec, and el, respectively.  For more information see the command.  The initial value for this toggle is TRUE in line-by-
		     line mode, and FALSE in character-at-a-time mode.

	      autoflush
		     Causes the command to not display any data on the user's terminal until the remote system acknowledges (via a  TELNET  Timing
		     Mark  option)  that  it  recognized  and  processed  the  following  TELNET sequences: ao, intr, or quit.	Both autoflush and
		     localchars must be TRUE for autoflush to work in this manner.  The initial value for this toggle is TRUE if the terminal user
		     did not specify Otherwise it is FALSE.  For further information, see

	      autosynch
		     Causes  the  TELNET  SYNCH sequence to follow the TELNET sequence that is initiated when either the intr or quit character is
		     typed.  The autosynch flag works in this manner when both the autosynch and localchars are TRUE.  This procedure should cause
		     the  remote  system  to  begin throwing away all previously typed input until both of the TELNET sequences have been read and
		     acted upon.  The initial value of this toggle is FALSE.

	      crmod
		     Toggles carriage return mode.  When this mode is enabled, most carriage return characters received from the remote  host  are
		     mapped  into  a  carriage	return followed by a line feed.  It is useful only when the remote host sends carriage returns but
		     never line feeds.	The initial value for this toggle is FALSE.

	      debug
		     Toggles socket level debugging which is useful only to the superuser.  The initial value for this toggle is FALSE.

	      options
		     Toggles the display of internal protocol processing that deals with TELNET options.  The initial value  for  this	toggle	is
		     FALSE.

	      netdata
		     Toggles the display of all network data (in hexadecimal format).  The initial value for this toggle is FALSE.

	      ?
		     Displays the legal toggle commands.

Restrictions
       In  line-by-line  mode,	the  terminal's EOF character is only recognized and sent to the remote system when it is the first character on a
       line.

																	telnet(1c)
All times are GMT -4. The time now is 10:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy