Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
Please learn to use CODE tags to make your scripts and data readable.
The problem is scope -- in some versions of shells, the pipe-into-while-loop is run in a separate process, so that variables are out of scope -- they no longer exist, and variables are not passed up from children to parents.
Some versions of Linux will have a recent version of ksh and allow your script to run as you wish (code omitted, paths and names made local):
However, a portable method would be to re-direct into the while loop, useful for pdksh, for example, on this different version of Linux:
Producing:
This is a common problem among shells. Moral: don't pipe into while loops ... cheers, drl
Hi,
i have a source file and have 3 columns and separated by "|" .i want to split this 3 columns in different variable.When i am executing this values indivisually giving correct result but when the same execute inside a for loop,it's giving issues.
Src file(jjj.txt)
-------... (8 Replies)
Hello,
I am running below command as root user
#nodetool cfstats tests | grep "Memtable switch count"
Memtable switch count: 12
Where as when I try to run same command as another user it gives different result.
#su -l zabbix -s /bin/bash -c "nodetool cfstats tests | grep "Memtable switch... (10 Replies)
Hello All,
We have a jave server running on both linux and Solaris environments.
On solaris,it consumes only 600-700MB whereas it goes upto 21G in Linux.
I am monitoring the memory consumption through top command.
Is this high memory consumption expected in Linux? (1 Reply)
Hi Guys,
I am developing a script to monitor GUI based FileNet Component "Component Manager" which logs it's running status in a log file.
Log file is a huge file so in script I put last 300 lines of log file in seperate file and run script every 5 minutes.
I am searching the string... (2 Replies)
Hi,
I need to copy files from a source directory to a destination directory in unix.
I'm using the file::copy for the actual copy.
The problem is that the source and dest directories are supplied by different users, who might type the name of the directories in various combinations of lower... (6 Replies)
my system get rebooted by its self after its came up i try to check the error log
P690/>errpt | more
Cannot open error message catalog /usr/lib/nls/msg/en_US/codepoint.cat.
The error report will still run, but it will not have explanatory messages
P690/>ls -lrt... (1 Reply)
Why does $0 return the word usage rather than the script name when used in a function?
Baffeled on this one, any help appreciated.
usage()
{
echo "$0 -cs <number of batches>\n"
echo "$0 -c 4"
echo "$0 -s 4"
# echo "-c = Create"
# echo "-s = Submit\n"
exit 1
}
$... (1 Reply)
Hi folks,
I am facing issue of my system (host1) getting hanged after throwing following ntpd messages. I am not able to ssh to the server there after. only option is to restart the host:
Dec 29 02:58:51 host1 ntpd: time reset -0.207907 s
Dec 29 02:58:51 host1 ntpd: synchronisation lost
Dec 29... (0 Replies)
I have five classes. 2 composition classes,1 aggregation class and 1 dependency class.I have coded all the classes but one of my test program is not giving me the expected result.I have the following classes:
TimeStamp
Interval (composition of 2 TimeStamps)
TimeSheet ( aggregation of many... (3 Replies)
Hi,
I am new to shell scripting and my below script is not giving result for 2 or more arguments. Can anyone help pls.
#!/bin/sh
sname=$(basename $(readlink -nf $0))
echo "This is $sname, running at $(date)"
echo "It is running on $(hostname)"
echo "Script being run by"
echo " User... (3 Replies)