CIFS file system check.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting CIFS file system check.
# 1  
Old 07-28-2010
CIFS file system check.

I have written a script to take backup of linux data on window's shared folder.
I have used following method in my script.
Code:
 mount -t cifs <windowshare> -o username=username,password=myPassword <mountlocation>

However most of linux system doesnt support CIFS filesystem.
How would i check if CIFS filesystem or service is present or not before executing the script?
# 2  
Old 07-28-2010
You may want to check the results of a faked mount, e.g.:

Code:
[root@leonov] mount -f -a; RV=$?; echo "Return Value: $RV"
Return Value: 0
[root@leonov] mount -f crap; RV=$?; echo "Return Value: $RV"
mount: can't find crap in /etc/fstab or /etc/mtab
Return Value: 1
[root@leonov] mount -f crap 2>/dev/null; RV=$?; echo "Return Value: $RV"
Return Value: 1

# 3  
Old 07-28-2010
Quote:
Originally Posted by dr.house
You may want to check the results of a faked mount, e.g.:

Code:
[root@leonov] mount -f -a; RV=$?; echo "Return Value: $RV"
Return Value: 0
[root@leonov] mount -f crap; RV=$?; echo "Return Value: $RV"
mount: can't find crap in /etc/fstab or /etc/mtab
Return Value: 1
[root@leonov] mount -f crap 2>/dev/null; RV=$?; echo "Return Value: $RV"
Return Value: 1


I have tried as u suggested but not getting what was desired.
for example

Code:
# mount -f cifs
mount: can't find cifs in /etc/fstab or /etc/mtab
[root@TomcatServer ntserver]# echo $?
1

However i can sucessfully mount the share using cifs on same machine.

Code:
mount -t cifs //10.180.8.23/downloads -o username=username,password=password /mnt/ntserver

# 4  
Old 07-28-2010
Quote:
Originally Posted by pinga123
Code:
mount -t cifs //10.180.8.23/downloads -o username=username,password=password /mnt/ntserver

Code:
mount -f -t cifs //10.180.8.23/downloads -o username=username,password=password; echo "$?"

# 5  
Old 07-29-2010
I will prefer to use following code.

Code:
HAVE_CIFS=no
grep -q cifs /proc/filesystems && HAVE_CIFS=yes
/sbin/modinfo cifs &>/dev/null && HAVE_CIFS=yes

if [ "x$HAVE_CIFS" = "xyes" ]; then
  ...
fi

# 6  
Old 07-29-2010
Why bother with a fake mount? Just go ahead and try to mount it for real. Before continuing with the script, check the exit status of the mount. If it succeeded, continue. If not, abort. You should be doing this anyway, as the mount could possibly fail for a different reason other than lack of cifs support.
# 7  
Old 07-29-2010
Quote:
Originally Posted by alister
Why bother with a fake mount? Just go ahead and try to mount it for real. Before continuing with the script, check the exit status of the mount. If it succeeded, continue. If not, abort. You should be doing this anyway, as the mount could possibly fail for a different reason other than lack of cifs support.
That should be a different reason.

Because if i go as per your suggestion the problem is i may not be able to recognize if cifs file system is supported or not.

According to me first file system check followed by status check for actual statement should be done.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy files with pattern from ext4 to cifs file system

Hi I have a shell script to copy a pattern of files from Linux to Windows Filesystem. When i execute the below command cp -av TOUT_05-02-13* Windows/Folder `TOUT_05-02-13-19:02:37.tar.gz' -> `Windows/Folder/SYSOUT_05-02-13-19:02:37.tar.gz' cp: cannot create regular file... (5 Replies)
Discussion started by: rakeshkumar
5 Replies

2. Shell Programming and Scripting

csh Check if file exists on remote system

I've seen this question posed a few times with shell scripting, but have not found anything with csh. I am trying to download multiple txt files from a source using wget. These are archived tornado warning files; however, the files only exist if there were tornado warnings issued that day. I'm... (3 Replies)
Discussion started by: meteorologistks
3 Replies

3. Shell Programming and Scripting

Script to check file system size

Dears, the output of this command df -h | tr -s ' ' | cut -f5 -d' ' is capacity 24% 0% 0% 0% 0% 1% 0% 24% 24% 0% 93% 1% (4 Replies)
Discussion started by: xxmasrawy
4 Replies

4. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

5. UNIX for Dummies Questions & Answers

How to check whether file system is local or NFS?

Hi, suppose I have file system path say /foo/bar/baz then how would I find out whether it is local file system or NFS? If it is NFS then I want to find out the host where file system is located. Thanks, Paresh (5 Replies)
Discussion started by: masaniparesh
5 Replies

6. Shell Programming and Scripting

File System Check using shell script !!!

Hi Guys I m posing this new thread as I didnt get satisfactory result after running search here. My requirement is very simple (using shell script) I need to findout what all file systems are mounted -> Then I need check the health of that file system - by disk usage & by doing a simple... (8 Replies)
Discussion started by: csaha
8 Replies

7. HP-UX

fsck! How to run Full File System Check

Dear all I am new for HP-UX. I have HP rp2470 running HP-UX 10.x When i run fsck in a root, the output is as below: #:root> fsck fsck: /dev/vg00/rlvol1: mounted file system continue (y/n)? y ** /dev/vg00/rlvol1 ** Last Mounted on /stand ** Phase 1 - Check Blocks and Sizes ** Phase... (3 Replies)
Discussion started by: hungevntelecom
3 Replies

8. Shell Programming and Scripting

check if file exists on remote system ?

Hi there, I am designing a software rollout script and need to check if a particular file exists on a remote system something along the lines of if ; then blah blah The above doesnt work but you get the general idea....is there a way I can do this on a single line ?? any help would... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

9. UNIX for Dummies Questions & Answers

File System Check (fsck)

I am having a problem with fsck. I am new to UNIX but was placed in a position where I must learn it. Anyway, one of the instructions that I have been given is to use 'fsck -f -y' when I am having trouble with the filesystem. The problem is that I am getting an error message that says the -f... (1 Reply)
Discussion started by: mawalton
1 Replies
Login or Register to Ask a Question