using Expect command to automate prgms
I'll be greatful if Any of u Scriptor's there can help me out automating A program that i need to run on every start up. Its called 24online. i need to run 24OnlineClient -u <username> then press Enter then is asks for password then i need to type my password & then it logs in.
I heard "Expect"(a tcl application) can do that user intake kionda thing along witha combination of a "send" command. the file is available at Sourceforge.net here http://sourceforge.net/projects/cyberoam |
Try creating a script "24connect"
Code:
#!/usr/bin/expect -f You can then call 24connect using: 24connect username password |
well i tried it but c'd not do it, probably i am very new to all this, Just a couple of quetions..
What does the "spawn" do. i think i must tell u the Exact thing i do. I have copied the executable to /usr/bin. at console i do this EXACTLY to make it login:- # 24 -u GaganPaul (then press enter) password: (asks password, put "cute" i.e. my passwd, enter) it then logs in & to check i ping yahoo.com. if ping is success i am logged into my gateway. Can u write me a Single file, doesnt need to have args as i can hardcode my username & pass(no security issues here) & just call it in the rc.d to autorun at start up |
It would help if you logged in manually and copied and pasted the output here (mask usernames and passwords - just so long as I know where they go). The reason for using arguments may be if you had 2 accounts etc - it is just for scalability.
|
Well i made my procedure Clear iin the 2nd post. wot i can Post u is the text iin the xterm that u can figure out how the program behaves. I already told u my userrname & password. no prbems of security as noone on this world can use that usrername & password specific to my LAN
----xterm text goes here----- root@scavan:~# 24 -u GaganPaul Password: root@scavan:~# -------------------------------------- no pls crefully see wot i tell u. 1. "24" is the binary i am running. -u is to give it username 2. "GaganPaul" is the username i pass to it & then press enter 3. asks for the password in next line 4. i put password "cute" there & press enter -----------extra------------ 5. no msg if login is Successful else it gives me "Try Again" 6. i ping yahoo.com just to check if i am conected to my gatewway. This prgm is a client for Cyberoam Server which runs on our Gateway server to authenticate the users on our LAN that share that gateway. we r on fixed Ip's. So when we login we need to run this program. only after we log in , we r given Access to internet. if u want better idea just downlad the binary from the Site mentioned above & have a look urself |
Sorry - missed that in your second post - I was probably doing too many things at once.
The script should probably be Code:
#!/usr/bin/expect -f |
i tried it all but no luck it gives the following error
cb is the file i made ;) ----------------------------------------- bash-2.05b# chmod +x cb bash-2.05b# ./cb spawn 24 -u GaganPaul Password:cute remove: No such file or directory sendto: Socket operation on non-socket bash-2.05b# cute bash: cute: command not found bash-2.05b# ------------------------------------------------------ when i say./cb it asks fpor the password exactly the way 24 does but when i put my password cute it displayes the error u can seee just elaborate wot spawn does actually so i may be able to help myself a bit. thx |
Spawn just starts the progam.
From the example there you don't have a space after the : did you do as I suggested in my last post and try it without the space? |
I also didn't type password with a capital P.
The expect string must match the line where the input is to occur exactly. |
No man it doesnt want to Run i get the same Shit again. i had tried the space there already, ya but i missed out that Caps P. Still i made the Corrections & get :-
------------ root@scavan:~/Desktop# ./cb spawn 24 -u GaganPaul Password: remove: No such file or directory sendto: Socket operation on non-socket root@scavan:~/Desktop# ------------ |
All times are GMT -5. The time now is 08:46 AM. |