LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-28-2004, 03:45 PM   #1
otisthegbs
Member
 
Registered: May 2003
Location: Vancouver
Distribution: RH9
Posts: 100

Rep: Reputation: 15
Bash command scripting


I need to automate some commands in my linux box. Primarily the htpasswd command for mini_httpd. I was wondering if there was a way to pass human interaction aurguments via some command operator....

The command I want to automate is
:#htpasswd .htpasswd (password file) admin (user)
New password for admin: Type password here
Retype password for admin Type password here
 
Old 06-28-2004, 03:54 PM   #2
SheldonPlankton
Member
 
Registered: Jun 2004
Posts: 129

Rep: Reputation: 15
Maybe you could use expect (http://expect.nist.gov/)
 
Old 06-28-2004, 03:56 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
htpasswd will also take the password as an argument.
 
Old 06-28-2004, 04:17 PM   #4
otisthegbs
Member
 
Registered: May 2003
Location: Vancouver
Distribution: RH9
Posts: 100

Original Poster
Rep: Reputation: 15
In the mini_httpd version of htpasswd, there is no option to pass the argument password.

Although that expect program looks totally rad, I wont have tcl in my embedded system
 
Old 06-29-2004, 12:33 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Does the mini_httpd version of htpassswd so anything different from that of apache? You could also write a simple perl script to do the encryption if you have perl installed.
 
Old 07-01-2004, 11:33 PM   #6
otisthegbs
Member
 
Registered: May 2003
Location: Vancouver
Distribution: RH9
Posts: 100

Original Poster
Rep: Reputation: 15
i do have perl installed, but unfortunatly im developing on a system of a different arch than the target, so i only have the main perl binary with nothing else. the perl binary i jacked off of the net and it was all i could find. (its a uclibc system if you're curious) so if you know of way of scripting it with the basic perl installed you would be gold!
 
Old 07-06-2004, 12:06 AM   #7
otisthegbs
Member
 
Registered: May 2003
Location: Vancouver
Distribution: RH9
Posts: 100

Original Poster
Rep: Reputation: 15
I figure it out



So i figured out what to do! if anyone for whatever reason is ever in the same situation as I, then here it is

In the htpasswd.c file of the mini_httpd source there is an if statement telling the session to prompt for a password and then to get the user to retype the password. Comment out the lines pertaining to retyping the password (which is done by puting a // in front of everyline) then recompile the program and issue the command:

%echo (your password here) | ./htpasswd -c (password file) (user name)

and BAM! its done

We wrote that command into a system call within a perl script and it works AOK!

Last edited by otisthegbs; 07-06-2004 at 12:07 AM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 10:15 AM
Bash Scripting help jgtg32a Programming 5 09-06-2005 09:38 AM
help on bash scripting Kendo1979 Linux - Newbie 3 05-17-2005 07:10 PM
Bash Scripting - echo command question gbhil Programming 2 04-27-2005 07:27 PM
Bash scripting JonCooperUK Programming 3 03-04-2004 08:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:26 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