Sponsored Content
Top Forums Shell Programming and Scripting script to tell whether there exists directory or not Post 302713011 by dbashyam on Wednesday 10th of October 2012 06:52:14 AM
Old 10-10-2012
Hi,

Thanks for your reply and the solution. But, I am struck a bit hope to get a lift from you.

Code:
#!/bin/sh
set -x
for i in `cat serverlist`; do
sleep 2
vtask $i ". /etc/profile.CA all; dsmver" > version.txt
ver=`awk '{while(match($0,/12\.5\.0\.2307/)) {  print substr($0,RSTART,RLENGTH) sub(/12\.5\.0\.2307/,"")}}' version.txt | sort -u`
echo $ver
if [ $? -eq 0 ];
then
print $i >> 12.5.txt
else
print $i >> 12.0.txt
fi
done

The output is shown below:
Code:
# ./agentversion.sh 
+ cat serverlist
+ sleep 2
+ vtask xxxxxx . /etc/profile.CA all; dsmver
+ 1> version.txt
+ + sort -u
+ awk {while(match($0,/12\.5\.0\.2307/)) {  print substr($0,RSTART,RLENGTH) sub(/12\.5\.0\.2307/,"")}} version.txt
ver=
+ echo

+ [ 0 -eq 0 ]
+ print yyyyyy
+ 1>> 12.5.txt
+ sleep 2
+ vruntask mmmmmm . /etc/profile.CA all; dsmver
+ 1> version.txt
+ + sort -u
+ awk {while(match($0,/12\.5\.0\.2307/)) {  print substr($0,RSTART,RLENGTH) sub(/12\.5\.0\.2307/,"")}} version.txt
ver=12.5.0.23071
+ echo 12.5.0.23071
12.5.0.23071
+ [ 0 -eq 0 ]
+ print ssssssss
+ 1>> 12.5.txt

what I want to know is even if the command does not find '12.5.0.2307' version in the server it still goes to the 12.5.txt file, I want if the command does not find the version as '12.5.0.2307' or it got disconnected it should go to 12.0.txt

The version.txt file has the following entries

12.5.0.2307
12.5.0.2307
12.5.0.2307

not sure why another '1' is added after 12.5.0.23071

Last edited by dbashyam; 10-10-2012 at 07:58 AM.. Reason: hiding the servername + added additional inputs
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check if directory exists

Hi, I need to prompt for a response from a user to enter a path read dest_dir?"Please Enter Directory :" How do I do this until a valid directory is entered by the user. I can use to check the existence of the directory. However when I try the following I cannot get it to work. while ... (2 Replies)
Discussion started by: jerardfjay
2 Replies

2. UNIX for Dummies Questions & Answers

Directory exists

Hi all, Sorry about this i'm sure this is a very silly question hence an easy answer but: I'm trying to write a script, part of which I want to check if a directory exists, if it doesn't then create it. Thanks for your help Tez (3 Replies)
Discussion started by: tez
3 Replies

3. Shell Programming and Scripting

how to check if masked directory exists?

I'm trying to write a script that identifies whether a directory of the form AWL.????????.IP exists. I have one that exists which is AWL.05301032.IP. When I test like this: If ] I get true, but when I test like this: If ] Or like this If ] Or any other variation of wild cards, I... (4 Replies)
Discussion started by: philplasma
4 Replies

4. UNIX for Dummies Questions & Answers

How can I check if directory exists in a makefile

Hi. I what to write a make file that inside a target I want to check if a directory exists. some like: ### make a: if ;then <command 1> else <command 2> fi ### make end Thanks a lot ---------------------- (2 Replies)
Discussion started by: zivsegal
2 Replies

5. Shell Programming and Scripting

Problem when test to see if directory exists

Hi, I'm writing a shell script that will create a folder if it does not exist yet. Here's the script: (this if statement is inside a while loop) folderName="Pics" if ! test -d folderName then mkdir $folderName fi However, after the folder Pics has been created, every time the... (3 Replies)
Discussion started by: trivektor
3 Replies

6. Shell Programming and Scripting

perl, if directory exists

Hi there I am trying to make a fuction that looks for a email profile that ends in .$ARGV here is the code if (-d "/Users/$ARGV/Library/Thunderbird/Profiles/*.$ARGV") { print "\n WARNING: Email profile already exits\n\n"; exit; } but for some reason it does... (2 Replies)
Discussion started by: ab52
2 Replies

7. Shell Programming and Scripting

how to check if a directory exists or not.if not need to create it

Hi, I am using solaris 10 OS and bash shell.just checking for small code snippet which follows below. /export/home/vomappservers/spa/common/5.0 /export/home/vomappservers/spa/common/scripts /export/home/vomappservers/spa/tools /export/home/vomappservers/spa/scm5.0/SCCS... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

8. Shell Programming and Scripting

Shell Script for generating NTIDs(Usernames) from the email ids which exists in MSAD Directory

Hi Everyone, I just need a shell script which automatically gives the list of NT IDs mean the Usernames from the list of email ids. We have around 140 users from AMERICAS,ASIAPACIFIC and EMEA User Directories and we have their email ids.For ex. i have email id called naveen-kumar.dasu@hp.com... (7 Replies)
Discussion started by: naveen.dasu
7 Replies

9. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

10. UNIX for Beginners Questions & Answers

Check that at least one file exists in the directory.

There are some files with suffix dates like abc_20032019.dat abc_17032019.dat If at least one file exists then perform some operation else exit from execution. Korn shell ---------------------------------- array=($inputdir/abc*.dat) If ] ] then echo " file exits" else echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies
INSTALLSIEVE(1) 					      General Commands Manual						   INSTALLSIEVE(1)

 *

NAME
installsieve - user utility for managing sieve scripts SYNOPSIS
installsieve DESCRIPTION
installsieve is a utility that allows users to manage their sieve scripts kept on the server. OPTIONS
-v <name> View script with the given name. The script if retrieved sucessfully is output to standard output. -l List all of the scripts currently on the server. If one of the scripts is active a arrow is printed indicating that it is the active script. -p <port> Port to connect to. If left off this defaults to "sieve" as defined in /etc/services. -i <file> Install a file onto the server. If a script with the same name already exists on the server it is overwritten. Upon sucessfully putting the script on the server the script is set active. If <file> has the extension .script it is chopped when put on the server since sieve names may not contain a '.'. -a <name> Set <name> as the active script. The list of available names can be obtained from the '-l' option.. -d <name> Delete the sieve script on the server with <name>. -m <mechanism> Force installsieve to use <mechanism> for authentication. If not specified the strongest authentication mechanism is chosen. -g <name> Get the sieve script with <name> and save it to disk with a ".script" extension. If a file with that name already exists it is overwritten. -u <user> Userid/Authname to use for authentication; by default, the current user. CMU
Project Cyrus INSTALLSIEVE(1)
All times are GMT -4. The time now is 01:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy