Doubt in running shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Doubt in running shell script
# 1  
Old 08-19-2008
Doubt in running shell script

Hi,
I'm a newbie in shell script.

I have a problem in running my a.out in a bash shell script named vetri . The following is the code.

#!bash/bin
./a.out abc.xyz

where ./a.out is a c++ bin file and abc.xyz is an argument. My ./a.out expects an input (cin >> temp). How can I give the input for my ./a.out file in shell script itself.
# 2  
Old 08-19-2008
I'm not certain I completly understand you but here's what I believe you are asking for:
Code:
#!/bin/bash
./a.out abc.xyz < your.input.file

Note that your header #!bash/bin is not likely to work correctly unless you have a very oddly located and named shell.
# 3  
Old 08-20-2008
# 4  
Old 08-20-2008
Hi Smiling Dragon,

My question is, I'm executing a C++ file inside a shell script. My C++ file expects an input ( a simple "cin >>" ). How can I give my input for C++ file in shell script itself.

Below is the code given.

Code:
#!/bin/bash
./a.out abc.xyz

a.out is my c++ executable and it's called with an argument abc.xyz. After executing this line, it will ask for an input to be entered from a keyboard.

All I wanted was, I should be able to set the input in shell script itself instead of entering it from keyboard.Just assume the input is defined. I didnt want to intervene.


~lchokka
# 5  
Old 08-20-2008
and my response is, read about HERE documents
Here document - Wikipedia, the free encyclopedia
# 6  
Old 08-20-2008
You can put that input inside the file 'your.input.file' or do as broli is saying and use the HERE syntax to pass the input to your program. Both will do what you're looking for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Oracle function invoked from shell script doubt

hi gurus, I have tried myself to invoke an oracle function. there are three different function available need to be called for differnt. can you tell me whether the below code is correct to call oracle function from shell script. Any help would be highly appreciated. cat location.sh ... (5 Replies)
Discussion started by: arun888
5 Replies

2. Shell Programming and Scripting

Cp not working in shell script but running perfectly from shell

Dear All, I have script. Dest="" IFS=' ' for translation in $(echo $MY_MAP) do t1=$(echo $translation | cut -d"=" -f1) t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1) if then Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2 break; ... (4 Replies)
Discussion started by: yadavricky
4 Replies

3. Shell Programming and Scripting

Changing shell from a script and running something from the new shell

Hi We use "tcsh" shell . We do the following steps manually: > exec ssh-agent zsh > python "heloo.py" (in the zsh shell) I am trying to do the steps above from a shell script This is what I have so far echo "Executing " exec ssh-agent zsh python "hello.py" exit 0 Problem is... (5 Replies)
Discussion started by: heman82
5 Replies

4. Shell Programming and Scripting

Shell script running command in different shell

Hi All, Is there any way where we can run few commands with different shell in a shell script ? Let's have an example below, My first line in script reads below, #!/bin/sh However due to some limitation of "/bin/sh" shell I wanted to use "/bin/bash" while executing few... (9 Replies)
Discussion started by: gr8_usk
9 Replies

5. Shell Programming and Scripting

plz help normal doubt abt shell script

How to print a only files and not directories in a path. for exam :a user consists both files and directoris in his path. i have to write a script to display only files not dirctories. and only dirctories not files. Advance thanks to forum members.:) (5 Replies)
Discussion started by: sivaranga001
5 Replies

6. Shell Programming and Scripting

Doubt in the daemon running script

Hi I was going through one of my pjct script .Please let me know the logic for the deamon is running or not as i think the condtn should be vice-versa. daemon_list = 'idp1278' FAIL=0 for p in ${daemon_list} do fail=0 ps -fu workarea | grep ${p} > /dev/null 2>&1 if ] then ... (1 Reply)
Discussion started by: mani_isha
1 Replies

7. Shell Programming and Scripting

shell script basic doubt

hi, I am new script learner, so my basic doubt is , how to store value of any command in a variable example $ ls | wc -l i want to stote the output of this in a variable c. so that i can use c in if else loop. and when do we use " ` " symbol in script.. can anyone also tell for... (5 Replies)
Discussion started by: hi2_t
5 Replies

8. Solaris

Running from Shell Vs running from RC script

Hi, i have a script which need to do behave differently when run as a startup process from init.d/ rc2.d script and when run manually from shell. How do i distinguish whether my script is run by init process or by shell?? Will the command /proc/$$/psinfo | grep "myscript" work well???... (2 Replies)
Discussion started by: vickylife
2 Replies

9. Shell Programming and Scripting

shell script doubt

Hi, While reading a shell script ,i have come accross the following statements. script_name_full=$0 ***script_name=${script_name_full##*\} ***script_name_noexst=${script_name%%\.ksh} host_name=`hostname` ***host_name_short=${host_name%%\.*} can anybody tell me what is the purpose of marked... (5 Replies)
Discussion started by: ravi raj kumar
5 Replies

10. UNIX for Dummies Questions & Answers

Unix + oracle doubt....involving shell script

....does the dbms_output.put_line work inside unix shell script? i mean this is to be inside the sqlplus connection as follows!! sqlplus -s $UP <<EOJ .. .. .. dbms_output.put_line ('Insertion procedure failed for UPC BC : ' || wk_key_value || ' Sqlcode: ' || SQLCODE || ' Error... (2 Replies)
Discussion started by: mexx_freedom
2 Replies
Login or Register to Ask a Question