tcsh: how to prevent a foreach from terminating a script when the result is null?
Sorry if this has been answered. I did search both Google and this site and did find this post: unix.com/unix-dummies-questions-answers/152992-how-ignore-errors-script.html
However, it wasn't answered.
I have the same question - how do you prevent a tcsh script from terminating when the result of a foreach is null?
So if my script does something like:
If the first foreach doesn't match anything, the entire script terminates with the error:
foreach: No match.
How do you prevent this? Do you have to do a check for the presence of anything you need to do a foreach on?
Dear all,
For example, if data contains following numbers:1 2 3 4 5 6
I would like get like below using foreach command,1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5 (1 Reply)
Hi everyone,
I am new to the linux.I wrote a small script and assigning two values to fname and lname and I want if the fname or lname are not given proper name like Toys or Gun the script should terminate and if they are given proper name it should execute.please help thanks:wall:
#!/bin/bash... (4 Replies)
So I am new to unix, and actually anything outside drag and drop with the mouse (been learning for about a week so far) . I have been using the foreach command in tcsh because I am working on a group of files. Basically what I need is to insert part of the filename as the first line in the file.... (0 Replies)
Hi,
I am writing a script on Solaris 10 and want to execute a remote ssh command. Normally this command should just return the value 0000000000002356 but when using ssh it seems it is passing the result to the shell to execute.
ssh root@10.5.112.145 `/usr/bin/nawk -F\, '$1=="USG" && $2=="01"... (3 Replies)
Hi all , i know i ask a lot of question but these are really hard to solve and important question. I send two scripts:
expect.sh:
#!/usr/local/bin/expect
spawn ssh root@172.30.64.163
expect "login:"
send "root\n"
expect "password:"
send "root\n^M"
interact
and
son.sh:
... (2 Replies)
I want to search line-by-line for a string in a file, and I want to do this to a series of files in a directory. I'm doing this in tcsh
This works fine to do the search:
while read i; do grep $i file2; done <file1.txt
This also works fine to read a directory:
foreach file ('/bin/ls... (1 Reply)
I now that this isnt the greatest code around. Im a network guy by trade not a programer .. but needed something to compare config files ...
Anyway ... intermittently, the program terminates.
Ive been looking at the code for a week trying to figure it out and Im stumped. Can anyone provide... (0 Replies)
Hi
I was working on a shell script with randomly shows a page of text from a randomly selected topic .As soon as the page is displayed it callers a timer script which keeps on running indefinitely until the timer script is killed by the user.
This is where I have the problem,if I press... (2 Replies)
Hi,
I'm trying to make a script that reads the console input and terminates with CTRL+D. It's absolutely basic but I don't know how to "read" the CTRL+D. I've tried a bunch of things like
EOT=^D
while //with & without quotations
do
read input
echo $input
done
while
while ]
... (12 Replies)