Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 21st, 2006, 8:54 PM   #1
ProjectX
Programmer
 
ProjectX's Avatar
 
Join Date: Feb 2005
Posts: 37
Rep Power: 0 ProjectX is on a distinguished road
Input help

I was gonna try something but I wanted to ask you guys if you could tell me if there is a way to insert a string into a shell command.
Ex: Lets say i have the script
#!usr/bin/perl

$su = "su";      # 'su' is a unix command
system($su);

and when you run it you get
$perl test.pl
Password:

so what i am asking is if there is a way to put the password into the Password field and then execute it.
ProjectX is offline   Reply With Quote
Old Feb 21st, 2006, 11:01 PM   #2
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 3 Kaja Fumei is on a distinguished road
You need to open a pipe to the other program and write to it.

#!usr/bin/perl

$pid = open(WRITEME, "| su") or die "Couldn't open $!\n";
print WRITEME "the_password\n";
close(WRITEME)                              or die "Couldn't close: $!\n";

For more info: http://www.unix.org.ua/orelly/perl/cookbook/ch16_05.htm
Kaja Fumei is offline   Reply With Quote
Old Feb 22nd, 2006, 8:31 AM   #3
ProjectX
Programmer
 
ProjectX's Avatar
 
Join Date: Feb 2005
Posts: 37
Rep Power: 0 ProjectX is on a distinguished road
thanks alot
ProjectX is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC