LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-27-2012, 01:42 AM   #16
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195

"gzip compressed data" should be an ordinary file for the purposes of the -f test.

What happens if you cd to the directory containing BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz and run this at the command prompt:
Code:
[[ -f BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz ]] && echo true || echo false
 
Old 02-28-2012, 05:59 AM   #17
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Original Poster
Rep: Reputation: 0
@catkin.

I get false

[user01@centos-flash]$[[ -f BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz ]] && echo true || echo false
false

Should it not come as "true"?

Where the stuff is going wrong?

--edit

Please note that tar file exist in that location.

Last edited by sysmicuser; 02-28-2012 at 09:13 AM.
 
Old 02-28-2012, 10:51 AM   #18
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Yes -- it should get "true". Very puzzling.

Trying to generate some more evidence, hopefully to gain understanding about why this is not working as expected, what happens if you do, at the command prompt (I know some of this is a repeat):
Code:
file='BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz'
file "$file"
[[ -a "$file" ]] && echo true || echo false
[[ -e "$file" ]] && echo true || echo false
[[ -f "$file" ]] && echo true || echo false
[[ -h "$file" ]] && echo true || echo false
[[ -r "$file" ]] && echo true || echo false
[[ -s "$file" ]] && echo true || echo false
[[ -w "$file" ]] && echo true || echo false
You should be able to copy that and paste it at the command prompt.
 
Old 02-28-2012, 11:00 AM   #19
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
(edit)
Sorry, missed the 1st page

Last edited by Cedrik; 02-28-2012 at 11:08 AM.
 
Old 02-29-2012, 05:31 AM   #20
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Original Poster
Rep: Reputation: 0
@catkin.

One shocking observation!

Have a look here.
Code:
[user01@centos-flash]$f1=BLD02CCA_PRE_1.9.0.6.6.3_UPGRADE_tmelbld12.tar.gz 
[user01@centos-flash]$[[ -f $f1 ]] && echo true || echo false
true
how come !!!
[user01@centos-flash]$file='BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz'
[user01@centos-flash]$file "$file"
BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz: ERROR: cannot open `BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz' (No such file or directory)
[user01@centos-flash]$[[ -a "$file" ]] && echo true || echo false
false
[user01@centos-flash]$[[ -e "$file" ]] && echo true || echo false
false
[user01@centos-flash]$[[ -f "$file" ]] && echo true || echo false
false
[user01@centos-flash]$
[user01@centos-flash]$[[ -h "$file" ]] && echo true || echo false
false
[user01@centos-flash]$[[ -r "$file" ]] && echo true || echo false
false
[user01@centos-flash]$[[ -s "$file" ]] && echo true || echo false
false
[user01@centos-flash]$[[ -w "$file" ]] && echo true || echo false
false
[user01@centos-flash]$
 
Old 02-29-2012, 05:37 AM   #21
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Not the same file...
Code:
f1=BLD02CCA_PRE_1.9.0.6.6.3_UPGRADE_tmelbld12.tar.gz
Code:
file='BLD02CCA_PRE_1.9.0.6.6.12_UPGRADE_tmelbld12.tar.gz'
 
Old 02-29-2012, 07:20 PM   #22
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Nice catch
 
Old 03-03-2012, 06:13 AM   #23
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Original Poster
Rep: Reputation: 0
Okay, to some of you I have no idea why the heck it is not working a simple -f test

Here we go.
f1=BLD02CCA_PRE_1.10_UPGRADE_tmelbld12.tar.gz
Code:
[user01@centos-flash]$[[ -f $f1 ]] && echo true || echo false
true
Now I have used pretty much same code
Code:
if [[ -f ${TAR_FILENAME} ]]
then
        echo "Application tar ball exist please check backup directory"
        exit 1
fi
But instead of failing the script simply continues! why?
 
Old 03-03-2012, 06:41 AM   #24
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
What happens if you add some debugging commands to the script:
Code:
echo "DEBUG: current working directory is: $( pwd )"
echo "DEBUG: TAR_FILENAME is: '$TAR_FILENAME'"
echo "DEBUG: ls -ld $TAR_FILENAME output is: $(ls -ld "$TAR_FILENAME" )"

if [[ -f ${TAR_FILENAME} ]]
then
        echo "Application tar ball exist please check backup directory"
        exit 1
fi
 
1 members found this post helpful.
Old 03-03-2012, 07:42 AM   #25
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

Original Poster
Rep: Reputation: 0
@catkin

you are GOD mate !!!

Issue is now identified!

The problem was the path in script was "relative" and not absolute path.

I said in script as TAR_FILENAME= blah blah but when script executed it didn't find file it did else part hwich is nothing and continued!!

The TAR_FILENAME variable is now fixed and script is pretty much rocking and rolling!

A big Thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Weird thing happening to my computer after installation dsplayer14 Slackware - Installation 4 11-12-2011 12:26 PM
strange thing happening with touchpad and http links and tabs with FF4 in latest RC vdemuth Slackware 2 03-30-2011 09:58 AM
Weird thing happening with graphics after update MTK358 Linux - General 2 04-11-2010 09:35 AM
Weird thing happening with GTK apps lancelott *BSD 0 06-22-2004 04:27 PM
Weird things are happening saiz66 Slackware 8 05-17-2003 01:03 AM


All times are GMT -5. The time now is 10:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration