Launching a C program that needs input from a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Launching a C program that needs input from a shell script
# 1  
Old 11-06-2009
Launching a C program that needs input from a shell script

hi there,
i need some help, i am trying to run a script to launch a C program and a Java program but before running both I want to get a user input and then invoke both programs with input received. In the programs the inputs are not command line arguments.

This is the code,
after the java bof and the ./bof.out how can I pass my $UserInput argument to both programs? And save the output from the 2 programs into two new arguments?

#!/bin/bash
#
#
clear
echo "Please enter a file name:"
read UserInput
echo "$UserInput"

java bof
./bof

Help is appreciated.
# 2  
Old 11-06-2009
Code:
#!/bin/bash
clear
echo "Please enter a file name:"
read UserInput
echo "$UserInput"

java bof $UserInput
./bof $UserInput

tyler_durden
# 3  
Old 11-06-2009
thanks tyler but both programs don't accept command line arguments. in a normal scenario you will run the program by typing

./bof.out
then you will be asked to input something, where I want to input the $UserInput

i tried this but it didn't work:

./bof.out <<$UserInput

any suggestions?
# 4  
Old 11-06-2009
Quote:
Originally Posted by momal
...
in a normal scenario you will run the program by typing
./bof.out
then you will be asked to input something, where I want to input the $UserInput
...
Then change the programs so that they process arguments passed to them rather than prompting for them.

tyler_durden
# 5  
Old 11-06-2009
isn't there another way to plug the arguments instead of passing them within the command line? if i change it to what you're suggesting then i'll loose the purpose coz I need to have a buffer over flow vulnerability there!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Launching mplayer from within Links2 using a shell script

I'm using the Links2 console web browser in graphical mode (the "-g" argument), and launching a shell script that invokes MPlayer from within it. MPlayer works fine. No problem there. The problem, is that I have no control over the MPlayer process. I would like to be able to exit MPlayer whenever... (16 Replies)
Discussion started by: ignatius
16 Replies

2. Shell Programming and Scripting

Seeing input that you redirect to a program on the shell

Suppose I have a program that I've written that accepts input, ie this C++ program: #include <iostream> using namespace std; int main() { cout << "Enter something:" << endl; int x; cin >> x; cout << "You entered data" << endl; } Suppose that I have a text file,... (5 Replies)
Discussion started by: Chris J
5 Replies

3. Shell Programming and Scripting

Write a shell program with input

Hi, Here is my question: I want a shell script which I name as 'del', and can be used as del(string). when run del(string), it will delete several directories at different locations in my system,like: rm -fr /lustre/fs/scratch/user/$string rm -fr /home/user/$string rm -fr... (4 Replies)
Discussion started by: 1988PF
4 Replies

4. Shell Programming and Scripting

Shell script to input as if from command line to the java program

Hi, We are having a java server which can run on command line and once initiated, it will prompt options to enter from 0 to 5. The java program kickoff respective operation once number is entered between 0 to 5. However i want to always enter "1" and write another shell program wrapper to start... (4 Replies)
Discussion started by: surya5kn
4 Replies

5. UNIX for Dummies Questions & Answers

how to pass input from c program to shell script?

Hello.. I am developing a Graphical User Interface using GTK. As part of our project I need to take inputs from GTK entries and pass those inputs to shell script and use them in shell script. The problem which struck me is only limited number of inputs are getting passed to shell script. For now... (14 Replies)
Discussion started by: kalyanilinux
14 Replies

6. Shell Programming and Scripting

Launching shell from another

hi, I have shell script ( say A.sh) that launches another shell script ( say B.sh) on the server. In shell script A.sh, if i call B.sh as . B.sh <-- it doesnt work, err file not found . ./B.sh <-- it doesnt work, err file not found ./B.sh <-- works why so? BTW the file exists at the... (4 Replies)
Discussion started by: sjc
4 Replies

7. Shell Programming and Scripting

Help to write a script or program to automatic execute and link input file data

Output file template format <input_file_name>a</input_file_name> <total_length_size>b</total_length_size> <log_10_length_size>c</log_10_length_size> Input_file_1 (eg. sample.txt) SDFSDGDGSFGRTREREYWW Parameter: a is equal to the input file name b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies

8. Shell Programming and Scripting

Shell variable to c++ program as input

I have an Shell script which has few global variables eg : range=100; echo "$range" I want to use the same variable in my C++ program for example int main() { cout << range << "\n"; } i tried using this int main(int argc, char *argv) { cout << range << "\n"; } but... (5 Replies)
Discussion started by: shashi792
5 Replies

9. Shell Programming and Scripting

input stored procedure to shell program

Hello, I have to call the stored procedure as argument from the unix shell program. Looks like unix doesnt like, can someone comment pls USERID=scott PASSWD=xxxxxx PLSQLCALL=$2 STDT=`sqlplus /nolog <<END >> $LOGFILE conn ${USERID}/${PASSWD}@${ORACLE_SID} whenever sqlerror exit failure... (9 Replies)
Discussion started by: tvanoop
9 Replies

10. Shell Programming and Scripting

Executing program with Perl script but needs user input

Hello, I'm running a perl script to execute a program through my Unix command line. The program requires a user input but I want to automatically have perl input the string. Is there a way to do this? Thanks (1 Reply)
Discussion started by: leonard2352
1 Replies
Login or Register to Ask a Question