unable to read a parameter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unable to read a parameter
# 15  
Old 07-08-2012
Quote:
Originally Posted by dhirajdsharma
Code:
cat newfile.txt | read temp

...<snip>...

[aeadmin@FNPRODXT1:/AELogs]$ ksh tivoliscript.ksh
tivoliscript.ksh[11]: test: 0403-021 A ] character is missing.

Quote:
Originally Posted by neutronscott
$temp won't be set for comparison. you'd need to set it without using a pipe.

Code:
temp=$(cat newfile.txt)
or
read temp < newfile.txt

It will be set, since ksh runs the final command of a pipeline in the current shell environment. Although ksh is the exception rather than the rule.

Regards,
Alister

P.S. Hi there, methyl, Scrutinizer, Corona Smilie
# 16  
Old 07-08-2012
Quote:
Originally Posted by alister
It will be set, since ksh runs the final command of a pipeline in the current shell environment. Although ksh is the exception rather than the rule.

Regards,
Alister

P.S. Hi there, methyl, Scrutinizer, Corona Smilie
my apologizes then. the "ksh" i've been using is flawed then.

Code:
$ mksh -c 'echo foo | read temp; echo "$temp"'

$ ksh93 -c  'echo foo | read temp; echo "$temp"'
foo

grr Smilie
This User Gave Thanks to neutronscott For This Post:
# 17  
Old 07-08-2012
Quote:
Originally Posted by neutronscott
my apologizes then. the "ksh" i've been using is flawed then.

Code:
$ mksh -c 'echo foo | read temp; echo "$temp"'

$ ksh93 -c  'echo foo | read temp; echo "$temp"'
foo

grr Smilie
Seems mksh behaves like bash (and bourne sh and dash and probably others) in that respect. Both ways are allowed by POSIX, but it's not very ksh-like.

Thank you for the heads up.

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Unable to read threads when logged in

I'm getting the following error (or something similar) whenever I try to view a thread when I'm logged in. That is, I login, hit "New Posts", get a list of theads, click on one (in this example is was the "Not allowed to post URLs" thread), then get the following HTML error page instead of the... (1 Reply)
Discussion started by: cnamejj
1 Replies

2. Post Here to Contact Site Administrators and Moderators

Unable to pass shell script parameter value to awk command in side the same script

Variable I have in my shell script diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new I could see value of $id is not passing to the awk... (0 Replies)
Discussion started by: Ashunayak
0 Replies

3. Shell Programming and Scripting

Read parameter file for a shell script

Hi All, I need urgent Help from all of you here. Below is my code- ================================================== #!/usr/bin/sh cd $1 cat $2 | tr -ds "$" "" > parameter_file.param export `parameter_file.param` chmod 777 parameter_file.param echo $1 echo $2 cd $prmDirInput... (5 Replies)
Discussion started by: Amit786
5 Replies

4. Shell Programming and Scripting

How to read a directory as parameter in shell script?

Hi All, I have written a shell script to compile an oracle R12 form and also a procedure is called from it. The procedure registers the form, function and creates a menu entry. I took directory as a parameter. Code is as below: #!/bin/ksh echo... (3 Replies)
Discussion started by: veena484
3 Replies

5. Shell Programming and Scripting

Unable to read Environment Variable

Hi I have created the following shell script file with the following content. #!/bin/csh set VAR1="abcxyz" << EOF EOF echo "---------------------" echo "VAR1 = $VAR1" echo "---------------------" i am not able to echo the previously set VAR1. Can any one suggested what could be wrong?... (5 Replies)
Discussion started by: srinu_b
5 Replies

6. Shell Programming and Scripting

Getting foreach to read a parameter with blank space

my program is designed to take the first parameters as extension, then the rest of the parameters as files to be searched for and, if found, modified by the extension. If not found, it prints an error. Everything is great until: ./chExt.sh 'com' 'king cobra.dat' where $file splits up the two... (2 Replies)
Discussion started by: username652719
2 Replies

7. Shell Programming and Scripting

Read parameter file in a shell script to unload a DB2 Table???

Hi , I Have following requirement: DB2 Sql query to pass from a parameter file for example, I would create a parameter file with (SELECT column 1, column 2 FROM Table name) then job would read it and create a file with the contents named table.txt How to write/modify below ksh script to... (10 Replies)
Discussion started by: developer.dwh9
10 Replies

8. Programming

unable to send a char parameter from main to a function

why does this not work? #include <stdio.h> #include <stdlib.h> char getFileMode(char charChanger) { char filetype; /*var to hold the value to be returned*/ filetype = charSetter; /*set filetype to "l" if it is a symlink*/ return filetype; } int main(void){ char... (8 Replies)
Discussion started by: bluetxxth
8 Replies

9. Shell Programming and Scripting

awk/sed script to read values from parameter files

Hi, I am writing a shell program that executes a lot of Oracle SQL Files on different databases based on the enviroment setting value. I am trying to design a parameter file where i can store the environment values for all the databases in the below format Environment File File Name... (6 Replies)
Discussion started by: rajan_san
6 Replies

10. Shell Programming and Scripting

Read from file as script parameter

I have a file with userIDs, one per line no spaces. I have a script that accepts userIDs as a parameter and outputs information about them. What I have had to do in the past was to modify each line of the file with userIDs to call the script with the userID and pipe the output to a data file. ... (2 Replies)
Discussion started by: vmaxx
2 Replies
Login or Register to Ask a Question