Sponsored Content
Full Discussion: problem with read command
Top Forums Shell Programming and Scripting problem with read command Post 302341457 by kshji on Thursday 6th of August 2009 03:28:00 AM
Old 08-06-2009
We have Posix-standard and then we have real world Smilie - people who has done the shells.

Only in ksh you can use pipe:
Code:
cmd | read var1 var2 ...


Previous zaxxon example include howto read generic one variable:
Code:
var=$( cmd )

Previous zaxxon example include howto read more than one variable using bash.
Code:
read var1 var2 <  <(cmd)

Generic version for more than one variable read:
Code:
read var1 var2 <<EOF
$(cmd)
EOF


Last edited by kshji; 08-06-2009 at 04:33 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SH script problem with read

Hi, I'm doing a script that reads lines from a file and then copy them to another file, if the user wants it. But I'having problems to get the user selection because when I do the read to ask the user, the script reads the next line of the file. The script looks like this: #!/bin/sh # ... (2 Replies)
Discussion started by: pmpx
2 Replies

2. Shell Programming and Scripting

Problem with read in sh

I've discovered a very annoying problem in sh: echo -en "one\ntwo\nthree" | while read VALUE do echo "${VALUE}" done This will print one and two, but not three. The last line is IGNORED because it lacks a newline. This makes it hard to use sh for things like CGI scripting; you have... (6 Replies)
Discussion started by: Corona688
6 Replies

3. Programming

Problem with read & write

Hello mates: I met problem with using read() & write(). I m trying to use read twice on client first time is the size of buffer, 2nd time is the buffer. I think I have to, coz I dnot know file size. So, I write twice on server as well -- 1st, filesize; 2nd, buffer. The problem is, sometimes,... (11 Replies)
Discussion started by: EltonSky
11 Replies

4. Programming

Problem in read() from a pipe

Hi, Can any one please help me with this. Am struggling hard to get a solution. I am doing telnet through a C program and getting the stdout file descriptor of the remote machine to pipe. read() function is getting data, But whenl it receives SOH character ie. ^A ( Start of heading = Console... (2 Replies)
Discussion started by: JDS
2 Replies

5. Shell Programming and Scripting

While Read problem

Hello, I have this simple script while read name do ssh $name "hostname > /tmp/$name.txt" ssh $name "/opt/ignite/bin/print_manifest | grep Main >> /tmp/$name.txt" ssh $name "getconf MACHINE_SERIAL >> /tmp/$name.txt" ssh $name "ioscan -kfnC processor | grep processor | wc -l >>... (3 Replies)
Discussion started by: Andyp2704
3 Replies

6. Shell Programming and Scripting

Problem to read archive

Dear all, I have this archive: cat file.txt archive test 02 sequence 03 02length 52 archive test 02 sequence 04 02length 52 archive test 02 sequence 05 02length 52 teste arquivo 06 sequencia 08 06 length 54 teste arquivo 06 sequencia 09 ... (8 Replies)
Discussion started by: cewa67
8 Replies

7. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

8. Shell Programming and Scripting

Problem with read line

Hi everybody, I am new to shell script. Please help me with this problem. I have a file test.txt with the content like this: I have a shell script test.sh like this #!/bin/sh while read line do echo $line >> out.txt done < test.txt out.txt is expected to have the same content... (10 Replies)
Discussion started by: Dark2Bright
10 Replies

9. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

10. UNIX for Beginners Questions & Answers

Read -p problem

Hi, :) I tried to make of "line returns" with "\n" : read -p $'Do you really want append this line in '$CONFIG_FILE''\n'IP CLIENT: '$IP_INPUT' - PATH: '$PATH_INPUT''\n'y/n ?:' CONFIRM_INPUT But it didn't work, please anyone have an idea? :b: (2 Replies)
Discussion started by: Arnaudh78
2 Replies
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/ksh93, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/ksh93, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh, and /usr/sfw/bin/zsh. /etc/shells overrides the default list. Invalid shells in /etc/shells could cause unexpected behavior, such as being unable to log in by way of ftp(1). FILES
/etc/shells list of shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.11 20 Nov 2007 shells(4)
All times are GMT -4. The time now is 02:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy