Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 39 guests and 1 member online
 
Advertisement

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Otherarrow scripting question
EH-Net
May 23, 2013, 04:12:28 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: scripting question  (Read 2727 times)
0 Members and 1 Guest are viewing this topic.
BillV
Hero Member
*****
Offline Offline

Posts: 1892


View Profile WWW
« on: October 02, 2011, 08:53:00 AM »

I want to run an app (call it 'app') and I want to automatically supply it with some responses that it requires, in order (say 'yes', 'no', 'maybe').

What is the proper way to do this? Google hasn't helped much or I haven't found the right way to phrase this in my searching.

The closest I have found was to do this:

yes | ./app

That's only for a single response (I need multiple) but my app just crashes at the first prompt anyway:

[yes|no]: yes: command not found

As if it's trying to run another script/app called 'yes' or something. I've also tried placing yes in single/double quotes with the same outcome.

Any suggestions would be great! Thanks!
Logged
hayabusa
Hero Member
*****
Offline Offline

Posts: 1633



View Profile
« Reply #1 on: October 02, 2011, 09:18:02 AM »

How about something like:

http://lists.gnu.org/archive/html/bug-bash/2007-01/msg00104.html

I haven't had to do auto responses to apps in a while, so you had me thinking...
Logged

~ hayabusa ~ 

"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'


OSCE, OSCP , GPEN, C|EH
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #2 on: October 02, 2011, 11:28:54 AM »

You could use "aliases" inside the bash shell, in case you want the "yes" command to do something with the word "yes", which is interpreted as a program which is not installed.

The way you want to supply an arg for 'app', is a bit non-standard.

Often, you could most likely supply arguments like this:
./app | perl -e 'print "Yes"'

I'm not sure if you can use this, but "xargs" may be what you are also looking for. Example command line:
find . | grep '.txt' | xargs cat

That would basically list all files (from the current directory recursively), show only those with .txt, and then "cat" each and one of them.

Basically, if you want to control this 'app', you need to either:
A) Run it and then redirect output, or pipe input into it like ./app | echo yes (or use python or perl for that sake), OR
B) Use a program or script infront of the APP, which supplies these "responses" to the program. E.g.:
./yes.py | app

yes.py contains the following code then:
print "yes"

You can of course, write a script that returns the response you give it, here's how you can do it in PHP:
#!/usr/bin/env php
<?php echo $argv[1]; ?>

Then chmod +x response php

./response.php yes | app

Basically just another way Smiley
Logged

I'm an InterN0T'er
BillV
Hero Member
*****
Offline Offline

Posts: 1892


View Profile WWW
« Reply #3 on: October 02, 2011, 08:07:35 PM »

Thanks for the ideas! I will try these out as soon as I get a chance and report back.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.07 seconds with 22 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Free Business and Tech Magazines and eBooks

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.