The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to write to stdin of another program (program A -> [stdin]program B) vvaidyan UNIX for Dummies Questions & Answers 3 08-02-2008 06:21 PM
How to write to stdin of another program (program A -> [stdin]program B) vvaidyan High Level Programming 1 04-30-2008 02:44 PM
Redirecting to stdin flame_eagle Shell Programming and Scripting 4 02-20-2008 04:25 PM
stdin marquis High Level Programming 2 04-14-2005 02:49 PM
stdin not tty when try to pine or redirect Micz UNIX for Dummies Questions & Answers 1 05-20-2004 03:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-03-2007
prkfriryce prkfriryce is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 44
redirect STDIN

can you redirect STDIN with command arguments?

I have tried this approach:


Code:
# ./script -option <argument1> <argument2> 0<$2 
# $2: ambiguous redirect

Is this possible?

Last edited by prkfriryce; 01-03-2007 at 05:37 PM..
  #2 (permalink)  
Old 01-03-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,800

Code:
myscript.sh arg1 < arg2

works from the command line that what you need?
  #3 (permalink)  
Old 01-03-2007
prkfriryce prkfriryce is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 44
Quote:
Originally Posted by jim mcnamara
Code:
myscript.sh arg1 < arg2

works from the command line that what you need?
nope.

in bash, it still tries to read arg2 as a text file:


Code:
# script -option arg1 < arg2
# arg2: No such file or directory

  #4 (permalink)  
Old 01-03-2007
iamcollins iamcollins is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
Hi

I am not clear with your exact requirement. If i am not mistaken, by default your input is going to be from STDIN.

One point to say here. Inside a shell script if there is any redirection of the standard input to a file, then subshells, functions and everything else also inherit the changed file descriptor. After that statement, your read will not get input from STDIN. In that case, you could use a read as mentioned below:

read newinput < /dev/tty

If think this is what you are asking for. If not, please provide the script you faced the problem, which would help to analyze and provide better solution saving time.
  #5 (permalink)  
Old 01-04-2007
prkfriryce prkfriryce is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 44
I am trying to automate the script without changing the script, or without waiting for the script to run, then inputing the STDIN from keyboard, tty, etc.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0