Dynamically locating a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dynamically locating a file
# 1  
Old 01-02-2009
Dynamically locating a file

Hi,
I have a requriement where in I need to install a s/w by executing the installable file through a script. The script currently contains the path of the installable file. I need to now update the script accordingly such tht it identifies the location of the installable file automatically and executes it.... I need to make the script path independent...

Can anyone pls help with regard to this.....

Thanks....
# 2  
Old 01-02-2009
If the installable file can be identified accurately by name only -
you really should have a checksum for it as well.
Code:
#!/bin/ksh
# i made up the checksum value :)  i'm using md5 - you can use cksum or whatever
mychecksum="2d786401096622f33b2cbed35c1bee39"  
file_to_execute=$(find / -type f  -user root -name install_file)
thischecksum=$(md5 $file_to_execute)

if [[ "$thischecksum" = "$mychecksum" ]] ; then
   $file_to_execute parm1 parm2 
else
   echo "no valid file found"
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamically split file

Hi guys, I have a file with 10000 entries (there are 2 columns. the first column contains the the product name and the second column contains the quantity of each product). I would like to split this file into 5 different files. I want the 1st entry to go to the fileA the 2nd entry to fileB... (3 Replies)
Discussion started by: coweb
3 Replies

2. Shell Programming and Scripting

Dynamically creating file names from portions of another file name

Not sure how to do the following, but any help would be appreciated. Has to be done using C shell (sorry about that). I have about 300 files that I need this done for, but I am only going to give one example. I will just need to know how to execute your solution through some type of loop to get... (2 Replies)
Discussion started by: jclanc8
2 Replies

3. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

4. UNIX for Dummies Questions & Answers

Locating a hidden file

it seems one of my server's account was compromised. I caught a perl script running a hack/attack script: 20:23 /usr/bin/perl ./up **.**.**.** 0 120 I've disabled the user etc, but I cannot find the script "up" anywhere in the server. I tried using locate or find. any ideas? (1 Reply)
Discussion started by: MaRiOsGR
1 Replies

5. UNIX for Dummies Questions & Answers

Read a file dynamically

Hi my requriment is read the file name dynamically my code is #!/bin/sh file="/c/work/loan/" Header_Trailer_move() { sed '1d;$d' $file| cat >sam.txt } Header_Trailer_move in above given path my list of files or there i have to read file dyanamically when i entered particular file name... (2 Replies)
Discussion started by: sgoud
2 Replies

6. UNIX for Dummies Questions & Answers

Locating and Extracting Specific Patterns from a file

Hi all, 1. I have a file that is getting continously refreshed (appended) I want to grep all the strings containing substring of the type abcdf123@aaa.xxx.yyy.zzz:portnumber: where, before @, any letters or numbers combination, after @, IP address then symbol : then port... (4 Replies)
Discussion started by: kokoras
4 Replies

7. Ubuntu

Help with locating a file (to download)

debian_base_system.tar.bz2 is what I am looking for. Hello All; I am trying to learn Linux and have done some work, now I am installing Xen virtual machine But I need a .tar.bz2 file which is the base Operating System (for Ubuntu or Debian)* but I do not know where to download it from, the... (2 Replies)
Discussion started by: Matey
2 Replies

8. Shell Programming and Scripting

Need to dynamically create a file

I'm trying to write a script that generates a file of varying size filled with random text and am having some difficulties. The major problems are that I'm limited to csh and a lot of the systems I have to run this on don't have a /dev/random (so a wrapper around the dd if=/dev/random or dd... (14 Replies)
Discussion started by: stareja
14 Replies

9. UNIX for Dummies Questions & Answers

locating the last file in the directory

i have few files in a directory.. i want to know , how to locate or display that last file in the directory which has the max date.. pls help (2 Replies)
Discussion started by: wip_vasikaran
2 Replies

10. UNIX for Advanced & Expert Users

dynamically linked file

Hi friends, i have a dynamically linked file on my solaris system.this is script that runs regularly. How can i read the contents of that ? when i tried to say "vi filename " then it says executable and nothing is seen. Please help. thanks in advance Veera (5 Replies)
Discussion started by: sveera
5 Replies
Login or Register to Ask a Question