If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > doing a login in from a script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-10-03, 14:58
jwdtacos jwdtacos is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
doing a login in from a script

Hey,

I am trying to create a script that will will log into a process and then exit.

The command is hastatus and I am trying to supply a username and password. How do I simulate a carriage-return and a ctrl-c to then exit the process. I need to then check if certain groups are offline.

This is what I have (that doesn't work). Any help would be greatly appreciated:

#!/usr/bin/ksh
VAR="netrac\n"
VAR1="qwer90\n"
printf $VAR
printf $VAR1
/opt/VRTSvcs/bin/hastatus <<!
printf $VAR
printf $VAR1
! >>
Reply With Quote
  #2 (permalink)  
Old 11-10-03, 16:07
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
in vi you can use CTRL-v to insert ESC-Sequenz.

Example : vi INSERT-Mode type CTRL-v and then ENTER. You get "^R".
This is an CR in shell enviromente. Also do with CTRL-c.
Type CTRL-v and then CTRL-c. You get a "^C" in vi.
CTRL-v only works for one character.

Peter F.
__________________
Greetings from germany
Peter F.

Last edited by fla5do; 11-10-03 at 16:37.
Reply With Quote
  #3 (permalink)  
Old 11-10-03, 19:58
jwdtacos jwdtacos is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
Thanks,

I still can't get a carriage return after the "VCS Login:" It runs the userid and password together and I need to send the userid, then CR, then th password at the password prompt, and enter. Then after the status has been shown, I need to ctrl-c. Unfortunately, I can't get the CR (^M) or the Ctrl-C (^C) to work.

Am I missing something?

This is what I have:

#!/bin/ksh
VAR=userid
VAR1=passwordval
/opt/VRTSvcs/bin/hastatus <<!
print $VAR^M
print $VAR1^M
sleep 15
^C
!>>

So, I'm trying to run the hastatus command, pass it the userid, CR, pass it the password, hit return, then ctrl-c out. When I run it I get this:

attempting to connect....
VCS Login:Password:
Reply With Quote
  #4 (permalink)  
Old 11-11-03, 12:21
pooja pooja is offline
Registered User
 
Join Date: Dec 2002
Posts: 104
Quote:
Originally posted by jwdtacos
Thanks,

I still can't get a carriage return after the "VCS Login:" It runs the userid and password together and I need to send the userid, then CR, then th password at the password prompt, and enter. Then after the status has been shown, I need to ctrl-c. Unfortunately, I can't get the CR (^M) or the Ctrl-C (^C) to work.

Am I missing something?

This is what I have:

#!/bin/ksh
VAR=userid
VAR1=passwordval
/opt/VRTSvcs/bin/hastatus <<!
print $VAR^M
print $VAR1^M
sleep 15
^C
!>>

So, I'm trying to run the hastatus command, pass it the userid, CR, pass it the password, hit return, then ctrl-c out. When I run it I get this:

attempting to connect....
VCS Login:Password:
hi!

Instead of print try using echo

For example:
#!/bin/ksh
VAR=userid
VAR1=passwordval
/opt/VRTSvcs/bin/hastatus <<!
echo $VAR
echo $VAR1
sleep 15


hope this will work

cheers,
Pooja
Reply With Quote
  #5 (permalink)  
Old 11-11-03, 12:38
jwdtacos jwdtacos is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
Hi, thanks.

I've tried that and just about everything else.

It seems like a buffer is getting flushed and it is not taking CRs or seeing the password value.

At this point I am left to trying to use the freely available autoexpect script in the expect module to try and write a non-interactive login script.

If anybody has any experience going this route, please feel free to advise me.

Thanks,
JD
Reply With Quote
  #6 (permalink)  
Old 11-12-03, 14:09
jwdtacos jwdtacos is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
Just as an FYI for everyone else, if you run into this problem with a command that is interactive or needs a username/password and shell scripting isn't doing the job, the freely available autoexpect script that comes with expect works beautifully.

You run it with the the interactive command as an argument and then interact with the command the normal way. Autoexpect will then create a script that will automatically do what you did.

Very nice.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On