| Author |
Message |
   
Saint
Legend Username: Saint
Post Number: 37151 Registered: 01-2011 Posted From: 12.22.163.132
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:57 pm: |
     |
Getafix: actually file checking on remote server ayithe perl best. Login to remote server with credentials and do listing on the filename and write it to an array and then disconnnect from remote host and check if the array is empty.. shell lo ayithe remote host meeda file test cheyalem.. you gotta get the filename someway to local host and then do the file test.
yes brother...! I did couple of projects on the similar concepts! every 5 minutes ki oka file vasthundi and it will have a seequence, I will have to download the files that are latest and then process them, and create another file for each file and ftp them to the server...! ade sequence mismatch vasthe, errors reporting, data ni 2 different types of databases loki load cheyyatam (oracle/sybase) and then each type of database lo,10-15 differnet DBs and multiple tables, each error okko type lo handling...abbo chala complicated process le motham!!jevitham ante virakthi vachindi!!2 years back chesina project! |
   
Humpty_dumpty
Moderator Username: Humpty_dumpty
Post Number: 27375 Registered: 02-2009
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:53 pm: |
     |
Alochinchu:
if you dont mind , i am just curious your program which calls unix script(s) ftp download/upload - it is a custom program or some job set up in a db server or something ? |
   
Getafix
Hero Username: Getafix
Post Number: 15276 Registered: 02-2008 Posted From: 12.151.251.178
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:28 pm: |
     |
Saint:sftp/ftp chesi file kooda down load cheyyali ante..perl is easy!!
actually file checking on remote server ayithe perl best. Login to remote server with credentials and do listing on the filename and write it to an array and then disconnnect from remote host and check if the array is empty.. shell lo ayithe remote host meeda file test cheyalem.. you gotta get the filename someway to local host and then do the file test. Just Sports! |
   
Getafix
Hero Username: Getafix
Post Number: 15275 Registered: 02-2008 Posted From: 12.151.251.178
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:25 pm: |
     |
Alochinchu:the above you are checking for the grep command.. what i am asking is after i found $? -ne 0 the script should return to the calling command with failure status..
if your calling program is also shell script then parent you can do like this rc=`call child program` and capture return code in $rc Just Sports! |
   
Alochinchu
Junior Artist Username: Alochinchu
Post Number: 883 Registered: 03-2008 Posted From: 65.51.27.62
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:25 pm: |
     |
Saint:sftp/ftp chesi file kooda down load cheyyali ante..perl is easy!!
yeah.. i use a different program that will call unix script i use scripts for outbound.. simple ga ftp login avvatamu.. download cheyyatamu.. but ippudu ftp login ayyina tharuvatha i have to check the file, if exists then script should return success other wise failure.. so that calling program will discontinue next steps.. |
   
Alochinchu
Junior Artist Username: Alochinchu
Post Number: 882 Registered: 03-2008 Posted From: 65.51.27.62
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:19 pm: |
     |
Saint:generally 0 is considered as success and 1 is failure! if I understand correctly you wnted to exit, your shell script with error code. if thats the case, use exit 1
Yes.. |
   
Saint
Legend Username: Saint
Post Number: 37149 Registered: 01-2011 Posted From: 12.22.163.132
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:18 pm: |
     |
Getafix:I would say go for perl script rather than shell. Shell lo 2 passes lo chesedi perl lo 1 pass lo cheyochu. And if your company mandates sftp which most of the companies are doing now..then it is much easier to manage in perl script over shell script.
I agree...ikkada file download ledu kadaa script lo..already vundoo ledoo check cheyyatam anthe!! sftp/ftp chesi file kooda down load cheyyali ante..perl is easy!! |
   
Alochinchu
Junior Artist Username: Alochinchu
Post Number: 881 Registered: 03-2008 Posted From: 65.51.27.62
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:17 pm: |
     |
Maverick:
that is for the unix command with in the script.. grep -i "check" /tmp/file1 if test $? -ne 0 ; then the above you are checking for the grep command.. what i am asking is after i found $? -ne 0 the script should return to the calling command with failure status.. |
   
Getafix
Hero Username: Getafix
Post Number: 15274 Registered: 02-2008 Posted From: 12.151.251.178
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:16 pm: |
     |
I would say go for perl script rather than shell. Shell lo 2 passes lo chesedi perl lo 1 pass lo cheyochu. And if your company mandates sftp which most of the companies are doing now..then it is much easier to manage in perl script over shell script. Just Sports! |
   
Getafix
Hero Username: Getafix
Post Number: 15273 Registered: 02-2008 Posted From: 12.151.251.178
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:14 pm: |
     |
Unix lo 0 is sucess and other than 0 is error. Just Sports! |
   
Maverick
Legend Username: Maverick
Post Number: 52082 Registered: 01-2008 Posted From: 69.174.58.188
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:12 pm: |
     |
Alochinchu:how to setup the return code (success or fail) in script?
check for $? Happy Vizag |
   
Saint
Legend Username: Saint
Post Number: 37148 Registered: 01-2011 Posted From: 12.22.163.132
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:12 pm: |
     |
Alochinchu:how to setup the return code (success or fail) in script?
generally 0 is considered as success and 1 is failure! if I understand correctly you wnted to exit, your shell script with error code. if thats the case, use exit 1 |
   
Alochinchu
Junior Artist Username: Alochinchu
Post Number: 880 Registered: 03-2008 Posted From: 65.51.27.62
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 04:10 pm: |
     |
how to setup the return code (success or fail) in script? |
   
Alochinchu
Junior Artist Username: Alochinchu
Post Number: 879 Registered: 03-2008 Posted From: 65.51.27.62
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:58 pm: |
     |
thanks guys... i am looking some what manthri and analog provided solutions.. |
   
Humpty_dumpty
Moderator Username: Humpty_dumpty
Post Number: 27374 Registered: 02-2009
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:44 pm: |
     |
Saint:You need another program / command like cron to schedule this program!
simble assumption that the program schedule is already decided in the reqs and run via cron, scheduler api etc |
   
Saint
Legend Username: Saint
Post Number: 37145 Registered: 01-2011 Posted From: 12.22.163.132
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:41 pm: |
     |
Question 1: hw frequently u would like to check for this file? Question 2: why do u want to write a shell script? in ur company, u dont have controlm or some job scheduler software? |
   
Saint
Legend Username: Saint
Post Number: 37144 Registered: 01-2011 Posted From: 12.22.163.132
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:40 pm: |
     |
Humpty_dumpty: if yes, programming language's file API should have a fileExists(String filePath) function or similar- that should be enough to check and quit prg withot calling unix script
ee programming language lo ina check sesukovachu file vunda leda anedhi!! not a big deal! but how frequently it shud check for file ? You need another program / command like cron to schedule this program! u can just write a shell loop and check for this file, if its unavailable, throw some message and get back to sleep mode! if ur intention is to load the data into oracle, oracle lo inbuilt feature vundi...sftp/ftp chesi file download chesi, process chesi load cheyyatam !!file leka poteh ignore madithi! |
   
Humpty_dumpty
Moderator Username: Humpty_dumpty
Post Number: 27372 Registered: 02-2009
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:37 pm: |
     |
if I got this str8 1. program written in a language like C, cpp, java etc downloads file from file server 2. program calls unix script to do something with the file if file is not available for step2...report failed status and quit program? if yes, programming language's file API should have a fileExists(String filePath) function or similar- that should be enough to check and quit prg withot calling unix script |
   
Maverick
Legend Username: Maverick
Post Number: 52080 Registered: 01-2008 Posted From: 69.174.58.188
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:28 pm: |
     |
unix file polling ani search kottu google lo Happy Vizag |
   
Analog
Side Hero Username: Analog
Post Number: 3296 Registered: 05-2008 Posted From: 129.110.242.50
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:24 pm: |
     |
crontab -u <username> <crontab> contents of cron tab file can be 00 8 * * * <check_for_file.sh> #Runs at 8Am am every day check_for_file.sh if [ -f $FILE ]; then echo "File $FILE exists" else echo "File $FILE does not exists" fi |
   
Manthri
Junior Artist Username: Manthri
Post Number: 218 Registered: 02-2013 Posted From: 63.165.163.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:19 pm: |
     |
SIZE=`ls -l <path>/<filename>|awk '{print $5}'` echo $SIZE if (( $SIZE=0 )) then <give failed status fi |
   
Analog
Side Hero Username: Analog
Post Number: 3295 Registered: 05-2008 Posted From: 129.110.242.50
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 03:09 pm: |
     |
setup a crontab script to check for this file everyday? |
   
Alochinchu
Junior Artist Username: Alochinchu
Post Number: 878 Registered: 03-2008 Posted From: 65.51.27.62
Rating: N/A Votes: 0 (Vote!) | | Posted on Thursday, July 17, 2014 - 02:55 pm: |
     |
i have to call a script from another program. the program gets the file from the client server through FTP and processes the file. The file frequency is unknown, usually twice a month but with no fixed dates. I want a script that checks for the file and should give me failed status if not exists so that i can quit the program with out processing. |