Hide Clipart | Topics | Search
Log Out | Register | Edit Profile
Last 30 mins | 1 | 2

Unix experts

Chalanachithram.com DB » New TF Industry Related » Archive through July 18, 2014 » Unix experts « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this 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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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 ?
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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..
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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..
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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!!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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..
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

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!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

Unix lo 0 is sucess and other than 0 is error.
Just Sports!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


Alochinchu:

how to setup the return code (success or fail) in script?




check for $?
Happy Vizag
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

how to setup the return code (success or fail) in script?
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

thanks guys... i am looking some what manthri and analog provided solutions..
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

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?
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)


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!
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

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
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

unix file polling ani search kottu google lo
Happy Vizag
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

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
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

SIZE=`ls -l <path>/<filename>|awk '{print $5}'`
echo $SIZE
if (( $SIZE=0 ))
then
<give failed status
fi
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

setup a crontab script to check for this file everyday?
Top of pagePrevious messageNext messageBottom of page Link to this message

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:   Insert Quote Edit PostDelete PostView Post/Check IPPrint Post   Move Post (Moderator/Admin Only)Ban Poster IP (Moderator/Admin only)

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.

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image HASH(0x83a5654){Movie Clipart}
Show / hide regular icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

 N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Show / Hide Filmy icons selection options

Click on following links to open cliparts by Alphabetical Order

 A   B   C   D   E   F   G   H   I   J   K   L   M  

 N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Username: Posting Information:
This is a public posting area. Enter your username and password if you have an account. Otherwise, enter your full name as your username and leave the password blank. Your e-mail address is optional.
Password:
E-mail:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: