How to copy script output to a variable using same script?
I'm trying to copy script output and use it in this same script as a variable, and call the variable when script is compiled.
The script is below.
If I use syntax OUTPUT=$(/usr/local/bin/script.sh) and run the script it hangs and does nothing.
We will assume that you understand that invoking script and invoking script.sh do not run the same code.
Most BSD, Linux, and UNIX systems have a utility named script installed. If you name your shell script script, whether you will invoke your shell script or the system's script utility will depend on which will be found first in the directories named by the PATH variable in your current shell execution environment.
If your script is named script and the directory containing your script is found in the PATH environment variable before the system's script utility, having the first thing that your code does be:
creates a recursive sequence of invocations of your script until you exceed that number of processes you are allowed to have running with your user ID, the system runs out of available resources to create another copy of your process, or a system administrator kills your job when other users on your system complain that you are slowing down their jobs by unreasonably consuming all available system resources.
The script is actually named read7.sh. It's not named script. I just wanted to emphasize that I'm running a script to capture it's output. Thanks for the valuable information.
Why don't you show us your actual script so we can see what it is really doing? There are obvious inconsistencies and/or misspellings that we don't know if they are typos in the way you have tried to emphasize features in your script or actual errors in your script.
It would help if the target were known - what do you want to achieve? Your code with the while loop and the grep gives wide room for interpretation and guesses - it doesn't realy make sense to me.
Hi- I am returning output of an query into a array variable in my shell script.
set -A DATE_RANGE `sqlplus -s **/**@** << EOF
set termout off
set echo off
set serveroutput off
set pagesize 0
set linesize 500
set heading off
set verify off
set feedback off
select... (1 Reply)
Hi Guys!
I'm trying to get this script going but running into a little issue. not sure what is going on.
basicly how i'm writing this script is to ask you what is the password you want to be encrypted, then ask you what the user id is, takes that info run's the encryption script with the... (2 Replies)
I'm running a matlab code within a shell script. This is how I do it,
matlab -nodesktop -nosplash -nojvm -r "my_program;quit"
This works fine. My matlab code prints out a single number, say "ans = 10" for example. I want to assign this to a variable in the shell script.
I tried doing this... (18 Replies)
Hi guys
I am calling one DB2 stored proc through unix. It is giving me below output. I want to capture the value 150 in one UNIX variable in shell script. Please let me know how I can achieve this. Thanks in advance
Value of output parameters
--------------------------
Parameter Name :... (5 Replies)
Hi,
We Perfrom Loads to the database through a Perl script which generates a statistics file. I need to read the statistics. the Statistics file looks something like below:
Process Beginning - 08-26-2010-23.41.47
DB2 CONNECTION SUCCESSFUL!
Ready to process and load file: FILENAME
# of... (2 Replies)
When script is running you only see when some of the commands are not successfull.
Is there a way to see which command are executed and to show the substitution of variables as every line is executed ? (3 Replies)
Hi,
I need to parse a simple text file like below and store the word that starts with BR* to a variable say $BRno. I need to do this in sh script.
NOTE: the length of the numbers following BR is not constant (eg: it could be BR1234 or BR22233). And there is only 1 BRxxxxx in a file at a given... (6 Replies)
Hi,
I work in ksh88.
I have an interective script which prompts the user for the input and returns numeric value depending on the input provided. I need to call this script inside another script and then assign the resulting output the the variable.
The call like that A=`my script` obviously... (6 Replies)
I'm sure this is a simple thing but I can't figure it out. In a script that I'm writing, I'd like to be able to store each line of output from "ls -l" into a variable. Ultimately I'd like to end up with something like:
for a in `ls -l`
do something with $a
doneBut that's reading each... (2 Replies)
Hi,
I wrote a script to get the oldest file from a directory path (which is passed as a parameter to the script)
#########################################################
XMLFILE_PATH={$1}
cd $XMLFILE_PATH
JPM_FILENAME = `(ls -tr User* | head -1)`
#echo $JPM_FILENAME
###### END... (1 Reply)