LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 07-05-2006, 07:52 AM   #1
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Rep: Reputation: 15
Shell Scripting


i have a program which my ISP has provided me to authenticate myself so that i can use the web.

It is called 24 online Client.

so i type
./24onlineClient -u [username]
then it says
Password:
the i type the password and then it authenticates me

I would like it to logon automatically every time i start my pc.

so i wrote a shell script

and put this command in and i plan to put it in rc.local or something.

But i have still not figured out how to provide this program with the password so that it automatically logs in without asking me for the password.

i tried ./24onlineclient -u [username] < pass.txt

and stored the password in pass.txt but it still asks for the password.

So any idea how i can get this done.

I am a newbie, so please dont use complicated terms.
 
Old 07-05-2006, 08:03 AM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 59
I don't know if this would work or not, because I can't really test it without that script, and even if I did have it I wouldn't be able to since I wouldn't authenticate with your ISP, but I'll give ya something to start with as a shot in the dark :
Code:
#!/bin/bash
# Define your authentication information
USER="YOURUSERNAME"
PASSWORD="YOURPASSWORD"

# And this is what I think may work 
echo -e "${PASSWORD}" | /path/to/client/24onlineclient -u ${USER}

# If you have to type password twice then just remove the next # symbol and use :
# echo -e "${PASSWORD}\n${PASSWORD}" | /path/to/client/24onlineclient -u ${USER}
I have no idea if that will work, but I guess it'll get ya started in your attempts

What I would try instead of keeping on rebooting, is just fill in your username and password above in the script, and just run the script and see if your online.
 
Old 07-05-2006, 11:35 PM   #3
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Original Poster
Rep: Reputation: 15
Hey i typed in that script but it still asks me for the password. I suppose that pipe is as good as a redirect
< symbol which is also not working. If you want to test it out, the client is available at

http://prdownload.berlios.de/cyberoa...x86-1.0.tar.gz

of course you wont get authenticated but all you have to check is that whether it prompts for the password or not. Just enter any 24online online server. It will probably work.
 
Old 07-06-2006, 12:39 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
If you don't get a real solution, I can describe a MONUMENTAL hack to accomplish this, using Gnu screen, and stuffing characters into it from a shell script. It's a bit complicated, so I'll hold off until a time of last resort.

--- rod.
 
Old 07-06-2006, 04:06 AM   #5
sameep
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Rep: Reputation: 0
Lightbulb

Hi... there is an alternative soultion.. I dont know how to get ure password into the script but u can get the alternate cyberoam client. There are a couple of alternatives to Cyberoams 24Online... you can google for them.. One which i used was Slyberoam.


P.S. u can also try linc-daemon
sourceforge.net/project/showfiles.php?group_id=55535


Hope it helpss

Last edited by sameep; 07-06-2006 at 04:10 AM.
 
Old 07-06-2006, 04:35 AM   #6
sudya
LQ Newbie
 
Registered: Mar 2005
Location: CA
Distribution: SuSE, Debian
Posts: 27

Rep: Reputation: 15
there is an option -f that will write a config file for you. Try to play around with that file, I saw there are couple of options about password. Save password and password fields might be your solution
 
Old 07-06-2006, 07:09 AM   #7
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Original Poster
Rep: Reputation: 15
i am not interested in the client.

I am interested in the shell scripting part.

So even if the client provides any option it does not matter.

I want to know how to supply the password via shell script.
 
Old 07-06-2006, 07:10 AM   #8
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Original Poster
Rep: Reputation: 15
i am not interested in the client.

I am interested in the shell scripting part.

So even if the client provides any option it does not matter.

I want to know how to supply the password via shell script.

please help.
 
Old 07-06-2006, 07:17 AM   #9
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Original Poster
Rep: Reputation: 15
sorry for the double post. I think cyberoam has an option of auto login.

But there must be some way to do it by shell scripting.

hey thenbomr, i dont mind that solution of course, if you can explain it of course.
 
Old 07-06-2006, 10:08 AM   #10
gkiagia
Member
 
Registered: Oct 2003
Location: Greece
Distribution: Debian sid
Posts: 248

Rep: Reputation: 30
I would also try this:
Code:
#!/bin/bash
# Define your authentication information
USER="YOURUSERNAME"
PASSWORD="YOURPASSWORD"

# And this is what I think may work 
echo -e "${PASSWORD}\n" | /path/to/client/24onlineclient -u ${USER}
The difference is that the password now ends with a newline character, which is what the enter key inserts. Normally, when it prompts you for the password, you type it in and then you press enter. The pipe passes the password to the program, but it doesn't press enter! So, with the \n character it might work.

I have tried the same trick in the past using a Qt/C++ program that tricks /usr/bin/sudo and passes it the root password to install rpm files. Here is part of the code:
Code:
QString password;
password = "mypassword";
password.append("\n"); // add a newline character at the end of the password
	
//Create process to do installation
rpminstall = new QProcess(this);
rpminstall->addArgument("/usr/bin/sudo");
rpminstall->addArgument("/bin/rpm");
if (vvBox->isChecked() )
    rpminstall->addArgument("-Uvv");
else
    rpminstall->addArgument("-Uvh");
if (forceBox->isChecked() )
    rpminstall->addArgument("--force");
if (nodepsBox->isChecked() )
    rpminstall->addArgument("--nodeps");
if (testBox->isChecked() )
    rpminstall->addArgument("--test");
rpminstall->addArgument(filename);
	
if ( !rpminstall->start() ) {
// error handling
QMessageBox::critical( 0, tr("Fatal error"), tr("Could not start the rpm command."), tr("Quit") );
exit( -1 );
}
rpminstall->writeToStdin(password); // pass the password to sudo
 
Old 07-06-2006, 11:21 AM   #11
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
It looks like the dialog to accept the login parameters is not reading from stdin, so no amount of stdio redirection is going to work. Another tack must be taken.

One method is to run the program inside of a gnu screen session. Screen allows one to 'stuff' characters into its console/tty input at a bit lower level, so we can 'type' into things that aren't reading stdin.

Code:
#!/bin/sh
#   ========= rc.local ===========
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.


PATH=$PATH:/usr/local/bin
export PATH

SCREEN_24ONLINE="24 Online"
USER_24ONLINE="JoeBloggs"
PASSWORD_24ONLINE="horty.florty"

#
#       We run the client application inside of Gnu screen sessions, so
#       we can monitor them and send commands to their interactive shells. We need
#       a way to create a tty for them at boot time. The Xvfb provides a virtual X server
#       to support an xterm that can in turn support a bash shell.
#
echo "Launching X virtual framebuffer"
Xvfb :1 -fbdir /tmp &

# We really should do something more robust for this...
echo "Snoozing while the virtual X server finds it's fonts..."
sleep 10

export DISPLAY="localhost:1"

echo "Starting 24 Online xterm/screen"
xterm -e screen -S "$SCREEN_24ONLINE" bash &

#
#       Q: So what is all this `echo -ne '\015'` stuff?
#       A: We are stuffing characters into a Gnu screen session, and
#          this is how we stuff a 'newline'


echo "Starting 24 Online"
screen -S "$SCREEN_24ONLINE" -X stuff "cd /dir/where/the/program/lives"`echo -ne '\015'`
screen -S "$SCREEN_24ONLINE" -X stuff "./24onlineClient -u $USER_24ONLINE"`echo -ne '\015'`

# Sleep a second while the program digests the entry... (may be required, or not)
sleep 1

screen -S "$SCREEN_24ONLINE" -X stuff "$PASSWORD_24ONLINE"`echo -ne '\015'`


echo Done
# ======================== End 24 Online setup ============================
#

The above is a modification of a method I use for launching an application at boot time.

The session will run as root, since it is run from rc.local. You may be able to use 'su' to change the user id when launching either screen or your 24 Online client. In order to access the running session, you can re-attach to the screen session with
Code:
screen -S "24 Online" -x
or, if you aren't already root
Code:
screen -S "root/24 Online" -x
If you are not the original owner of the screen session (probably root), you will have to have set up screen in multiuser mode by adding a line
Code:
multiuser on
to /etc/screenrc

You can test things using a normal shell script, and once the wrinkles are ironed out, put it into rc.local
I suggest reading up on gnu screen, a priori. Note also the inherent insecurity of embedding a password into a plaintext file. Caveat emptor.

I told you this was a monumental hack, did I not?

Enjoy.

--- rod.

Last edited by theNbomr; 07-06-2006 at 11:23 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell scripting adamuk Programming 5 06-08-2006 04:04 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM
shell scripting Prasun1 Linux - General 1 06-23-2005 08:38 AM


All times are GMT -5. The time now is 11:53 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration