I tried the change but it didn't help.. here is the result. Any other idea's... Thanks for your help with this.
$ cat maldo_sleep
typeset -i count
typeset -i tcount
count=0
tcount=0
while $tcount <= 11
do
print "\$count is $count"
pwd
ls -l
sleep 30
$(($tcount=$count+1))
$count=$tcount
done
$ ./maldo_sleep
./maldo_sleep[7]: 0: not found
$
Hi!
There are actually two errors in your script:
testing a variable doesn't work that way. You have to use test - external or built-in, I don't remember how this is in ksh - hence, I'll show the "old-fashioned way" :-) see your ksh manual page, look for keyword test.
you are using < in your test. for shell, less-than means input redirection from a file
So, this should work:
I also don't quite understand the way incrementation of tcount is done. Simple
Regards,
pen
Last edited by pen; 07-30-2009 at 02:00 AM..
Reason: syntax error
Hey all. Thanks in advance for any help you can give, hopefully this is an easy one. I want to create a loop to run a simple performance monitor like vmstat and record it to a file, but have very limited scripting skills (obviously).
Starting with this...
date >> /var/log/perfmon.log
vmstat... (2 Replies)
i have the following process running in background:
when i give "ps -lef"
------------------------------------------------------------------------
user2
user1
user1
user3
user1
user4
user5
user4
user3
user4
user2
user1
user1
user3
user1
user4 (3 Replies)
i have a script called file2
#!/bin/ksh
i=0
while
do
echo $i >> result.txt
i=`expr $i + 1`
done
echo "***********************" >> result
------------------------------------------------------------------- (10 Replies)
I have what I believe is a simple programming question. I have a text file that looks like:
mol 1 G:\stereo01.hin
block text
...
...
...
endmol 1
However, I would like a file that repeats this entire block of text several times over. The lines of text in the middle remain the same for each... (2 Replies)
Hello forum memebers.
can you correct the simple while program.
#! /bin/ksh
count=10
while
do
echo $count
count='expr$count-1'
done
I think it will print 10 to 1 numbers but it running for indefinite times. (2 Replies)
Hello all!
This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician.
Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix:
... (16 Replies)
Dear experts,
I am writing a bash script. At some point of the program I need to have 'for' loop. For simplicity I tried with some other simple code. The format of the loop is given below.
k=51
m=55
for j in {$k..$m};do
w=$(($j+2))
z=$(($j+9))
echo "$w, $z"
done
But my... (4 Replies)
Hi,
I am completely new to shell scripting. Basically I am wanting to create a simple while loop script to check if a network connection is available from 'netstat -a' and if its present then output a character to the serial port. I think i am nearly there.. but need some assistance.. this is... (9 Replies)
Hi all,
Please guide me writing this script
Follwing is the file which I have created, which contains the files to be copied.
cat system1-dr.txt
/etc/passwd
/etc/shadow
/etc/group
/etc/vfstab
/etc/profile
/etc/default/init
/etc/shells
/etc/dfs/dfstab
/etc/dfs/sharetab... (11 Replies)
Dear unix wizards,
I'd be very grateful for your help with the following.
I have a hypothetical file (file.txt) with three columns:
111 4 0.01
112 3 0.02
113 2 0.03
114 1 0.04
115 1 0.06
116 2 0.02
117 3 0.01
118 4 0.05
Column 2 consists of pairs of integers from 1 to 4 (each... (5 Replies)
Discussion started by: aberg
5 Replies
LEARN ABOUT LINUX
typeset
typeset(1) User Commands typeset(1)NAME
typeset, whence - shell built-in functions to set/get attributes and values for shell variables and functions
SYNOPSIS
typeset [ +- HLRZfilrtux [n]] [ name [ = value]]...
whence [-pv] name...
DESCRIPTION
typeset sets attributes and values for shell variables and functions. When typeset is invoked inside a function, a new instance of the
variables name is created. The variables value and type are restored when the function completes. The following list of attributes may be
specified:
-H This flag provides UNIX to host-name file mapping on non-UNIX machines.
-L Left justify and remove leading blanks from value. If n is non-zero it defines the width of the field; otherwise, it is determined
by the width of the value of first assignment. When the variable is assigned to, it is filled on the right with blanks or trun-
cated, if necessary, to fit into the field. Leading zeros are removed if the -Z flag is also set. The -R flag is turned off.
-R Right justify and fill with leading blanks. If n is non-zero it defines the width of the field, otherwise it is determined by the
width of the value of first assignment. The field is left filled with blanks or truncated from the end if the variable is reas-
signed. The -L flag is turned off.
-Z Right justify and fill with leading zeros if the first non-blank character is a digit and the -L flag has not been set. If n is
non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment.
-f The names refer to function names rather than variable names. No assignments can be made and the only other valid flags are -t, -u
and -x. The flag -t turns on execution tracing for this function. The flag -u causes this function to be marked undefined. The
FPATH variable will be searched to find the function definition when the function is referenced. The flag -x allows the func-
tion definition to remain in effect across shell procedures invoked by name.
-i Parameter is an integer. This makes arithmetic faster. If n is non-zero it defines the output arithmetic base; otherwise, the
first assignment determines the output base.
-l All upper-case characters are converted to lower-case. The upper-case flag, -u is turned off.
-r The given names are marked readonly and these names cannot be changed by subsequent assignment.
-t Tags the variables. Tags are user definable and have no special meaning to the shell.
-u All lower-case characters are converted to upper-case characters. The lower-case flag, -l is turned off.
-x The given names are marked for automatic export to the environment of subsequently-executed commands.
The -i attribute can not be specified along with -R, -L, -Z, or -f.
Using + rather than - causes these flags to be turned off. If no name arguments are given but flags are specified, a list of names (and
optionally the values) of the variables which have these flags set is printed. (Using + rather than - keeps the values from being
printed.) If no names and flags are given, the names and attributes of all variables are printed.
For each name, whence indicates how it would be interpreted if used as a command name.
The -v flag produces a more verbose report.
The -p flag does a path search for name even if name is an alias, a function, or a reserved word.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO ksh(1), set(1), sh(1), attributes(5)SunOS 5.10 1 Feb 1995 typeset(1)