LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-10-2017, 11:58 AM   #1
jillbuck
LQ Newbie
 
Registered: Apr 2017
Posts: 1

Rep: Reputation: Disabled
concatenate username, password and program object


before moving to Linux in the AIX world, we would run the cat command to pass the username and password to the program object like this:

USR=/directory/name.usr
PASS=/directory/name.pass
file=/directory/obj/programobject
outfile=/directory/outfile.txt

cat $USR $PASS | $file > $outfile 2>&1

Now that we have moved to Linux, this no longer works. The user is read in by the program to be userpassword and the password read in by the program is blank. I cannot find a way to force each variable to be a separate parameter, one username and one password.

How can I fix this?
 
Old 04-10-2017, 12:14 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Hi jill buck and welcome to LQ.

Using Bash, you can enable verbose output by issuing the "set -xv" command, and you can do that at the start of a script, or in the command line. To disable this you issue the "set +xv" command. Note you need only disable in the command line. A script will start a new process, which will complete and the setting will not be retained. This will allow you to debug your lines.

You create a new file using the I/O redirection argument: >
You can append to a file using the I/O redirection argument: >>

This is not AIX, nor are the file structures for username and password saved anywhere. Are these files which you are creating, or on AIX were you reading system files? In Linux, the passwords are not stored in plain text, so any attempt to echo them will not work. If you have created these files, then that will work, however it is dangerous to do so.

I haven't tested, but I suspect that the cat will not like two file names together, otherwise all seems fine. So you may have to do two cat function calls, and thus one creates the file and the second one appends to it.

Enabling the verbose output will give you a better idea where the problem with your script exactly is.

You may not be using the Bash shell, but it is one of the most common ones. Issue the command:
Code:
$ echo $0
to get an output of which shell you are using.

Please also reply to tell us if this is a script, or a series of command line arguments.

Last edited by rtmistler; 04-10-2017 at 12:16 PM.
 
Old 04-10-2017, 12:26 PM   #3
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,345

Rep: Reputation: Disabled
Quote:
Originally Posted by jillbuck View Post
cat $USR $PASS | $file > $outfile 2>&1
This basically says "send the contents of the files $USR and $PASS to stdout, which should then be redirected to the input of the program $file". That will work in one scenario and one scenario only:
  1. $file expects the user to type in a username and a password,
  2. the combined contents of $USR and $PASS matches exactly what $file expects to see, and
  3. the application $file accepts input redirection
I suspect (3) might be the issue. Many GNU applications (like passwd) are explicitly made not to accept passwords from stdin. If you want to automate a login process, or really any interactive command line operation, you should take a look at expect.

Last edited by Ser Olmy; 04-10-2017 at 12:32 PM.
 
  


Reply



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
How to username password and sort by weakest password rhbegin Programming 8 11-07-2012 08:39 AM
[SOLVED] Passing another program a password and username felix001 Programming 15 05-14-2010 09:56 AM
username and password a7mlinux Linux - Security 14 08-11-2009 10:27 AM
Username/Password Help FindingWaldo763 Linux - Newbie 7 12-18-2005 07:15 PM
Username and Password dance2die Arch 3 09-01-2003 03:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:19 PM.

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
Open Source Consulting | Domain Registration