Register
It is currently Tue Oct 21, 2014 12:22 pm

help with input output redirect


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Mon Jan 24, 2011 11:53 pm   

Joined: Mon Jan 24, 2011 11:48 pm
Posts: 2
I use a program which is invoked from terminal as
"solid.x <nacl_6_ravi.dat > nacl_6_ravi.out"
How do I store the variables "nacl_6_ravi.dat" and "nacl_6_ravi.out" in a shell script? ( actually I want to call that script from my fortran program and use those two variables)
call get_command_argument doesnot give anything except solid.x


Top
 Profile  
 PostPosted: Tue Jan 25, 2011 1:05 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
hi,

would you use a bash script inside a C program, to use another program ? what you want to do seems as silly as that.

anyway, you've been told.

here is my bash.script:
Code:
#!/bin/bash

echo "$1"
echo "$2"
here are the commands to use it
Code:
chmod u+x ./bash.script
./bash.script abc def
the result will be:
Code:
abc
def
because abc is the first argument (first positional parameter)
I let guess what is def
:))


Top
 Profile  
 PostPosted: Thu Jan 27, 2011 4:45 am   

Joined: Mon Jan 24, 2011 11:48 pm
Posts: 2
Hi dear,
Your method would fail if I use
Code:
./script.scr <abc > def

Because, shell will need a file named abc. So making just ./script.scr abc def will not solve the problem.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP