The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
strange "No such file or directory" errors on NFS volumes fishsponge UNIX for Advanced & Expert Users 3 06-17-2008 12:37 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 09:52 PM
"syntax error at line 21 :'done' unexpected." error message" ibroxy Shell Programming and Scripting 3 08-08-2007 03:45 AM
Help! "Bus error" and "CPU Panic" box wont boot hcclnoodles SUN Solaris 3 10-05-2006 01:38 PM
dbx error ("Executable contains object file compiled on ...") Sabari Nath S High Level Programming 0 08-04-2005 02:03 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Feb 2007
Posts: 21
Stumble this Post!
Keep getting error "No such file or directory"

Hi,

When I try to run this script I keep getting the error "/quota.sh: fgrep 5162 /home/nasadmin/quotas_michel/userlist.txt: No such file or directory" but when i run this command typed in I do get the correct output. Can somebody help me?

This is the script:

Code:
# Omgevingsvariabelen instellen
#-------------------------------------------------------------------------------------------
NAS_DB=/nas
NAS_BIN=${NAS_DB}/bin
NAS_SBIN=${NAS_DB}/sbin
PATH=${PATH}:${NAS_BIN}:${NAS_SBIN}
export NAS_DB PATH
REPORT_ROOT=/home/nasadmin/quotas_michel

# datum ophalen
#-------------------------------------------------------------------------------------------
  REPORT_DATE=`date +%D,%T`


# Lijst met gebruikers ophalen
#-------------------------------------------------------------------------------------------
  cat /nas/cifs/usrmapperV3/autoumupload/server_2_newpasswd | cut -d\: -f1,3,5 > userlist.txt

# Lijsten genereren van filesystemen waar quota's op staan
#-------------------------------------------------------------------------------------------


  
        nas_quotas -user -report -fs user1  > user1.txt
        cat user1.txt | while read LINE
        do
                USERID=`echo $LINE | cut -f 2 -d\| | cut -d# -f2`
                USED=`echo $LINE | cut -f3 -d\|`
                SOFT=`echo $LINE | cut -f4 -d\|`
                HARD=`echo $LINE | cut -f5 -d\|`
                UTEMP=`"fgrep $USERID $REPORT_ROOT/userlist.txt"`
        done
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Remove the double quotes
Code:
UTEMP=`fgrep $USERID $REPORT_ROOT/userlist.txt`
Reply With Quote
  #3 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Feb 2007
Posts: 21
Stumble this Post!
Removing double quotes loses my variable

If I remove the double quotes I lose the variable.. then the error becomes "fgrep: :: No such file or directory"
Reply With Quote
  #4 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
can you show trace of your script?
Reply With Quote
  #5 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Feb 2007
Posts: 21
Stumble this Post!
Trace?

Do you meen this with trace?

Code:
[nasadmin@ns600cs_kk4 quotas_michel]$ ./quota.sh
fgrep: for: No such file or directory
fgrep: user: No such file or directory
fgrep: quotas: No such file or directory
fgrep: on: No such file or directory
fgrep: filesystem: No such file or directory
fgrep: user1: No such file or directory
fgrep: mounted: No such file or directory
fgrep: on: No such file or directory
fgrep: /root_vdm_1/user1:: No such file or directory
Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
+------------+---------------------------------+-------------------------------+
fgrep: :: No such file or directory
User
+------------+--------+-------+-------+--------+--------+------+------+--------+
fgrep: :: No such file or directory

+------------+--------+-------+-------+--------+--------+------+------+--------+
fgrep: :: No such file or directory
5003
fgrep: :: No such file or directory
5005
fgrep: :: No such file or directory
5006
fgrep: :: No such file or directory
5007
Reply With Quote
  #6 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Stumble this Post!
Add this code at the start of your script and show the trace
Code:
set -vx
Reply With Quote
  #7 (permalink)  
Old 02-14-2007
Registered User
 

Join Date: Feb 2007
Posts: 21
Stumble this Post!
trace

Code:
#-------------------------------------------------------------------------------------------
NAS_DB=/nas
++ NAS_DB=/nas
NAS_BIN=${NAS_DB}/bin
++ NAS_BIN=/nas/bin
NAS_SBIN=${NAS_DB}/sbin
++ NAS_SBIN=/nas/sbin
PATH=${PATH}:${NAS_BIN}:${NAS_SBIN}
++ PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/nasadmin/bin:/nas/bin:/nas/bin:/nas/sbin
export NAS_DB PATH
++ export NAS_DB PATH
REPORT_ROOT=/home/nasadmin/quotas_michel
++ REPORT_ROOT=/home/nasadmin/quotas_michel

# datum ophalen
#-------------------------------------------------------------------------------------------
  REPORT_DATE=`date +%D,%T`
date +%D,%T
+++ date +%D,%T
++ REPORT_DATE=02/14/07,11:30:28


# Lijst met gebruikers ophalen
#-------------------------------------------------------------------------------------------
  cat /nas/cifs/usrmapperV3/autoumupload/server_2_newpasswd | cut -d\: -f1,3,5 > userlist.txt
++ cat /nas/cifs/usrmapperV3/autoumupload/server_2_newpasswd
++ cut -d: -f1,3,5

# Lijsten genereren van filesystemen waar quota's op staan
#-------------------------------------------------------------------------------------------


  #for i in 1
  #do
        nas_quotas -user -report -fs user1  > user1.txt
++ nas_quotas -user -report -fs user1
        cat user1.txt | while read LINE
        do
                USERID=`echo $LINE | cut -f 2 -d\| | cut -d# -f2`
                USED=`echo $LINE | cut -f3 -d\|`
                SOFT=`echo $LINE | cut -f4 -d\|`
                HARD=`echo $LINE | cut -f5 -d\|`
                UTEMP=`fgrep \:$USERID\: /home/nasadmin/quotas_michel/userlist.txt`

                #USERNAME=`echo $UTEMP | cut -d: -f1`
                echo $USERID
        done
++ cat user1.txt
++ read LINE
echo $LINE | cut -f 2 -d\| | cut -d# -f2
+++ echo Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
+++ cut -f 2 '-d|'
+++ cut -d# -f2
++ USERID=Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
echo $LINE | cut -f3 -d\|
+++ echo Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
+++ cut -f3 '-d|'
++ USED=Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
echo $LINE | cut -f4 -d\|
+++ echo Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
+++ cut -f4 '-d|'
++ SOFT=Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
echo $LINE | cut -f5 -d\|
+++ echo Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
+++ cut -f5 '-d|'
++ HARD=Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
fgrep \:$USERID\: /home/nasadmin/quotas_michel/userlist.txt
+++ fgrep :Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1: /home/nasadmin/quotas_michel/userlist.txt
fgrep: for: No such file or directory
fgrep: user: No such file or directory
fgrep: quotas: No such file or directory
fgrep: on: No such file or directory
fgrep: filesystem: No such file or directory
fgrep: user1: No such file or directory
fgrep: mounted: No such file or directory
fgrep: on: No such file or directory
fgrep: /root_vdm_1/user1:: No such file or directory
++ UTEMP=
++ echo Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
Report for user quotas on filesystem user1 mounted on /root_vdm_1/user1
++ read LINE
echo $LINE | cut -f 2 -d\| | cut -d# -f2
+++ echo +------------+---------------------------------+-------------------------------+
+++ cut -f 2 '-d|'
+++ cut -d# -f2
++ USERID=+------------+---------------------------------+-------------------------------+
echo $LINE | cut -f3 -d\|
+++ echo +------------+---------------------------------+-------------------------------+
+++ cut -f3 '-d|'
++ USED=+------------+---------------------------------+-------------------------------+
echo $LINE | cut -f4 -d\|
+++ echo +------------+---------------------------------+-------------------------------+
+++ cut -f4 '-d|'
++ SOFT=+------------+---------------------------------+-------------------------------+
echo $LINE | cut -f5 -d\|
+++ echo +------------+---------------------------------+-------------------------------+
+++ cut -f5 '-d|'
++ HARD=+------------+---------------------------------+-------------------------------+
fgrep \:$USERID\: /home/nasadmin/quotas_michel/userlist.txt
+++ fgrep :+------------+---------------------------------+-------------------------------+: /home/nasadmin/quotas_michel/userlist.txt
++ UTEMP=
++ echo +------------+---------------------------------+-------------------------------+
+------------+---------------------------------+-------------------------------+
++ read LINE
echo $LINE | cut -f 2 -d\| | cut -d# -f2
+++ echo '|User' '|' Bytes Used '(1K)' '|' Files '|'
+++ cut -f 2 '-d|'
+++ cut -d# -f2
++ USERID=User
echo $LINE | cut -f3 -d\|
+++ echo '|User' '|' Bytes Used '(1K)' '|' Files '|'
+++ cut -f3 '-d|'
++ USED= Bytes Used (1K)
echo $LINE | cut -f4 -d\|
+++ echo '|User' '|' Bytes Used '(1K)' '|' Files '|'
+++ cut -f4 '-d|'
++ SOFT= Files
echo $LINE | cut -f5 -d\|
+++ echo '|User' '|' Bytes Used '(1K)' '|' Files '|'
+++ cut -f5 '-d|'
++ HARD=
fgrep \:$USERID\: /home/nasadmin/quotas_michel/userlist.txt
+++ fgrep :User : /home/nasadmin/quotas_michel/userlist.txt
fgrep: :: No such file or directory
++ UTEMP=
++ echo User
User
++ read LINE
echo $LINE | cut -f 2 -d\| | cut -d# -f2
+++ echo +------------+--------+-------+-------+--------+--------+------+------+--------+
+++ cut -f 2 '-d|'
+++ cut -d# -f2
++ USERID=+------------+--------+-------+-------+--------+--------+------+------+--------+
echo $LINE | cut -f3 -d\|
+++ echo +------------+--------+-------+-------+--------+--------+------+------+--------+
+++ cut -f3 '-d|'
++ USED=+------------+--------+-------+-------+--------+--------+------+------+--------+
echo $LINE | cut -f4 -d\|
+++ echo +------------+--------+-------+-------+--------+--------+------+------+--------+
+++ cut -f4 '-d|'
++ SOFT=+------------+--------+-------+-------+--------+--------+------+------+--------+
echo $LINE | cut -f5 -d\|
+++ echo +------------+--------+-------+-------+--------+--------+------+------+--------+
+++ cut -f5 '-d|'
++ HARD=+------------+--------+-------+-------+--------+--------+------+------+--------+
fgrep \:$USERID\: /home/nasadmin/quotas_michel/userlist.txt
+++ fgrep :+------------+--------+-------+-------+--------+--------+------+------+--------+: /home/nasadmin/quotas_michel/userlist.txt
++ UTEMP=
++ echo +------------+--------+-------+-------+--------+--------+------+------+--------+
+------------+--------+-------+-------+--------+--------+------+------+--------+
++ read LINE
echo $LINE | cut -f 2 -d\| | cut -d# -f2
+++ echo '|' '|' Used '|' Soft '|' Hard '|Timeleft|' Used '|' Soft '|' Hard '|Timeleft|'
+++ cut -f 2 '-d|'
+++ cut -d# -f2
++ USERID=
echo $LINE | cut -f3 -d\|
+++ echo '|' '|' Used '|' Soft '|' Hard '|Timeleft|' Used '|' Soft '|' Hard '|Timeleft|'
+++ cut -f3 '-d|'
++ USED= Used
echo $LINE | cut -f4 -d\|
+++ echo '|' '|' Used '|' Soft '|' Hard '|Timeleft|' Used '|' Soft '|' Hard '|Timeleft|'
+++ cut -f4 '-d|'
++ SOFT= Soft
echo $LINE | cut -f5 -d\|
+++ echo '|' '|' Used '|' Soft '|' Hard '|Timeleft|' Used '|' Soft '|' Hard '|Timeleft|'
+++ cut -f5 '-d|'
++ HARD= Hard
fgrep \:$USERID\: /home/nasadmin/quotas_michel/userlist.txt
+++ fgrep : : /home/nasadmin/quotas_michel/userlist.txt
fgrep: :: No such file or directory
[nasadmin@ns600cs_kk4 quotas_michel]$ less errorlog.txt
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0