01-16-2007
loop does not execute in bash script?
I have a very basic bash shell script, which has many "while... done; for .... done" loop clauses, like the following
~~
#!/bin/bash
while blablalba; do
....
done < /tmp/file
for line in `cat blablabla`; do grep $line /tmp/raw ; done > /tmp/1;
while blablalba2; do
....
done < /tmp/file2
~~
I noticed there are some loop conditions will never be executed, for example,
"for line in `cat blablabla`; do grep $line /tmp/raw ; done > /tmp/1;"
I am sure all the the loop clauses are right, since I can execute them without problem in command line, so whats wrong with my script? what should I pay attention?
Thanks!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hello. we are porting over from HPUX Shell to Linux.
my default shell is bash so i can no longer schedule to execute a sh script in crontab.
can anyone pls help me out? I searched the site but didnt find any details.
thanks! (1 Reply)
Discussion started by: jigarlakhani
1 Replies
2. Shell Programming and Scripting
I can't get any bash scripts to run in Terminal (Mac - Snow Leopard). I have the following super-simple script, and I can't get it to execute despite having the correct permissions (I think).
#!/bin/bash
echo "WORK... PLEASE?!"
I named the file 'testScript.sh', and I added execution... (6 Replies)
Discussion started by: compulsiveguile
6 Replies
3. Shell Programming and Scripting
I have a file as follows:
cat /etc/mxg/ssh-hostsmx.example1.com.au:2225
mx2.example2.com.au:2225
mx.example3.com.au:2225
mail.example4.com.au:2225
mail.example5.org.au:2225
mail.example6.com.au:2225I want to dynamically create aliases for quick access to these servers from bash. I wrote... (4 Replies)
Discussion started by: jelloir
4 Replies
4. Shell Programming and Scripting
Hi all!
I am trying to write a script that will check if a certain directory is available at several different nodes and then do stuff in it .....
On the beginning of the script I give as a variable the directory and the number of the nodes and then I loop like this:
for... (3 Replies)
Discussion started by: idet2
3 Replies
5. Shell Programming and Scripting
Hi All,
I am trying to write a simple bash script.
rm -f File1
I saved this as test.sh
Now when I want to execute it, I type ./test.sh
It gives me error "command not found"
What I am doing incorrect here? Do I have to add anything in script like
#!/bin/bash (5 Replies)
Discussion started by: palak08
5 Replies
6. UNIX for Dummies Questions & Answers
I just can't figure it out , so please just give me a pice of advise how to:
The existing Linux program foo2bar takes as its only argument the name of a single foo file and converts it to an appropriately-named bar file. Provide a script that when executed will run foo2bar against all foo... (4 Replies)
Discussion started by: raymen
4 Replies
7. Shell Programming and Scripting
Hello,
I am running into few issues, please suggest me what I am missing.
I am running this script on a linux host.
Main idea of this script is to, login to each host via ssh and get uid of user, service user that I trying to run this script, has already deployed ssh keys and provide sudo... (8 Replies)
Discussion started by: bobby320
8 Replies
8. Programming
Hi
I have a bash script which takes parameters
sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC
gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash
I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies
9. Shell Programming and Scripting
Hi,
I have first script which on IR remote command event execute the second script. If the second script is executed, it display echo "timeout expired" after 10s. This works as expected.
But I also want to reset timer (increase time) in case if the second script is executed again within 10s.
... (8 Replies)
Discussion started by: armatron
8 Replies
10. Shell Programming and Scripting
I am trying to loop through lots and lots of folders and use the names of the folders to run a Python script which has parameters.
E.g.
-- setup_refs -n John -f England/London/Hackney/John -c con/con.cnf
Normally to run `setup_refs` once from command line it's: `python setup_refs.py -n John... (3 Replies)
Discussion started by: Mr_Keystrokes
3 Replies
LEARN ABOUT DEBIAN
copymsg
copymsg(9F) Kernel Functions for Drivers copymsg(9F)
NAME
copymsg - copy a message
SYNOPSIS
#include <sys/stream.h>
mblk_t *copymsg(mblk_t *mp);
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
PARAMETERS
mp Pointer to the message to be copied.
DESCRIPTION
copymsg() forms a new message by allocating new message blocks, and copying the contents of the message referred to by mp (using the
copyb(9F) function). It returns a pointer to the new message.
RETURN VALUES
If the copy is successful, copymsg() returns a pointer to the new message. Otherwise, it returns a NULL pointer.
CONTEXT
copymsg() can be called from user or interrupt context.
EXAMPLES
Example 1: : Using copymsg
The routine lctouc() converts all the lowercase ASCII characters in the message to uppercase. If the reference count is greater than one
(line 8), then the message is shared, and must be copied before changing the contents of the data buffer. If the call to the copymsg()
function fails (line 9), return NULL (line 10), otherwise, free the original message (line 11). If the reference count was equal to 1, the
message can be modified. For each character (line 16) in each message block (line 15), if it is a lowercase letter, convert it to an upper-
case letter (line 18). A pointer to the converted message is returned (line 21).
1 mblk_t *lctouc(mp)
2 mblk_t *mp;
3 {
4 mblk_t *cmp;
5 mblk_t *tmp;
6 unsigned char *cp;
7
8 if (mp->b_datap->db_ref > 1) {
9 if ((cmp = copymsg(mp)) == NULL)
10 return (NULL);
11 freemsg(mp);
12 } else {
13 cmp = mp;
14 }
15 for (tmp = cmp; tmp; tmp = tmp->b_cont) {
16 for (cp = tmp->b_rptr; cp < tmp->b_wptr; cp++) {
17 if ((*cp <= 'z') && (*cp >= 'a'))
18 *cp -= 0x20;
19 }
20 }
21 return(cmp);
22 }
SEE ALSO
allocb(9F), copyb(9F), msgb(9S)
Writing Device Drivers
STREAMS Programming Guide
SunOS 5.10 27 Jun 1995 copymsg(9F)