UNIX automation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UNIX automation
# 29  
Old 01-21-2011
Quote:
Originally Posted by j_panky
@ctsgnb - Thanks the above script of yours is working fine but there is one issue in it....
It is not an issue : in my post #25 i asked :

Quote:
Originally Posted by ctsgnb
2) What do you want to happen if a number is missing in the sequence ?

a) Do you want the script to continue to the next sequence number ?
or
b) Do you want the script to abort ?

Please be clear about your requirements.
... and you answered :

Quote:
Originally Posted by j_panky
"OK...Now if any number is missing it should check for the next number if it is present then the script should continue and if not then it should come out of the loop sayin hmmm next number not present or what ever echo message...."
So it is the expected behaviour you request in your previous post.

That is the reason why i asked you to be more clear in your requirements.


But to answer your question, since your requirement have changed and you now want that missing sequence number don't get out of the loop :

you just need to remove the || break in the following line :
Code:
chk_file "${filename}" || break

to
Code:
chk_file "${filename}"


Last edited by ctsgnb; 01-21-2011 at 05:12 AM..
# 30  
Old 01-21-2011
ya i want the script to continue to the next sequence number.
I thought if the while loop is upto 100 the script will go till 100..\yes i want the script to continue untill it finds the last sequence number.
# 31  
Old 01-21-2011
remove the || break in the line

Code:
chk_file "${filename}" || break

and give a try
# 32  
Old 01-25-2011
@ctsgnb - Thanks its working absolutely fine...
Slight change i need in the script as it throwing an error on the scrren when i execute your script.
Error -

What i want is, when ever the two files are found (1. or 2. or any with Fe.ok) then the my_script should get executed.This is going pretty well.

But for example if 20.akfjakf file is not available it give message stating
Code:
ls: 20.*: No such file or directory
ls: 20.*: No such file or directory
 is the filename
File missing:

This message should not display on screeen as i cannot deploy such script on production with these messages.
Also becoz on while loop which is "while [ $i -lt 100 ]" on screen it is giving many times such messages if the files are not available.
Any clue how can the script be changed.

Last edited by j_panky; 01-25-2011 at 04:01 AM..
# 33  
Old 01-25-2011
Needs to lose the error channel from "ls" to prevent the error messages.
Code:
if [ $(ls $i.* 2>/dev/null | wc -l) -gt 1 ]
filename=$(ls $i.* 2>/dev/null)
filename2=$(ls *Fe.ok 2>/dev/null | tail -1)

This may ripple further into the logic of the script but I have lost the plot on what the script is meant to do.
# 34  
Old 01-27-2011
  • @ctsgnb Can you pls comment for my changes in the requirement as @methyl has lost the plot.
# 35  
Old 01-27-2011
Quote:
Originally Posted by j_panky
  • @ctsgnb Can you pls comment for my changes in the requirement as @methyl has lost the plot.
change

Code:
if [ $(ls $i.* | wc -l 2>/dev/null) -gt 1 ]

with
Code:
if [ $((ls $i.* | wc -l) 2>/dev/null) -gt 1 ]

also change
Code:
filename=$(ls $i.*)
filename2=$(ls *Fe.ok | tail -1)

with
Code:
filename=$((ls $i.*) 2>/dev/null)
filename2=$((ls *Fe.ok | tail -1) 2>/dev/null)

and give another try
This User Gave Thanks to ctsgnb For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automation using bots in Linux/UNIX ?

Hi folks, has any one attempted using bots for performing tasks in unix?please share if you faced any challenges thanks (1 Reply)
Discussion started by: tommy812
1 Replies

2. Post Here to Contact Site Administrators and Moderators

UNIX automation

I am using netteza server and i have a list of table names. I need to fetch all the data from these tables and need to create seperate zip files and store in a folder in the server. How can we automate this process. (1 Reply)
Discussion started by: nikhilthms97
1 Replies

3. Shell Programming and Scripting

Unix fdisk -l Automation

Hello Folks - Need help really ASAP. Iam trying to run this Shell command to get all the lists of partitions and disks from across all the servers. #!/bin/ksh _servers="" _out="/tmp/output.$$" _ssh=/usr/bin/ssh >$_out for s in $_servers do $_ssh $s fdisk -l >> $_out done ... (8 Replies)
Discussion started by: bkilaru
8 Replies

4. Homework & Coursework Questions

Mail Automation in UNIX

Hi Sir, I need unix code which will read data present in .xls file and should send an automated mails .when i place the .XLS file in a specific folder and run ***.sh from unix box Attached Excel file contains Subject , To , CC , Body (Paragraph 1) , Body (Paragraph 2) , Signature When i... (2 Replies)
Discussion started by: chaitanyaS
2 Replies

5. Shell Programming and Scripting

creating an automation process in unix .

hi i need shell script in ksh for the automation process in informtica. The automation process is like this . i have a folder in unix . when this folder gets updated (like if a file or files is/are added to the folder) an event in informatica is triggered and after the process is done in... (2 Replies)
Discussion started by: kumar8887
2 Replies

6. Shell Programming and Scripting

Simple Unix Automation

Hi, i'm a newbie with unix and shell scripting. I'm just trying to do a script to simply automate a unix task. This are the steps on what i want to just run on a simple shell script 1. go to a specific path (cd /folder1/folder2/) 2. edit and input a number on a file (file_id) then save exit... (6 Replies)
Discussion started by: soultransit
6 Replies

7. Shell Programming and Scripting

Test automation tool for UNIX ??

I am searching for a automation testing tool which I can use for most of the UNIX platforms (AIX, Linux, HP UX, Solaris). The installation process of the application in all platforms is almost same. Are you aware of any automation tool (like WinRunner for Windows) to solve my problem? (5 Replies)
Discussion started by: unmanju
5 Replies

8. UNIX for Advanced & Expert Users

automation of Informatica jobs using Unix

1.How will you do automation of Informatica jobs using Unix ? 2. How u run workflow from Unix? :) (2 Replies)
Discussion started by: kamesh83
2 Replies

9. Cybersecurity

FTP Automation Windows <> Unix <> Remote

Hi All, I am a newbie to unix and scripting. I need to do the following job: 1. Create a batch file in windows that will call a script in a remote unix box. 2. The script now ftp files from the Remote windows machine and get them back to the local windows. Actually, I have written the script... (3 Replies)
Discussion started by: Ankur
3 Replies
Login or Register to Ask a Question