Link to home
Start Free TrialLog in
Avatar of techmiss
techmissFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Unix Script Not Giving Desired Result

Hi all,

I am using the command:

mount -t cifs //10.41.5.242/warehouse -o username=warehouse,password=password /mnt/warehouse_win

This command works ok, however when I put it in a script it returns with the error:

"mount error: can not change directory into mount target /mnt/warehouse_win"

I have whittled down my script so it now only contains the mount command to try and eliminate the problem so i've obviously donw something wrong somewhere.

Cheers
K

Avatar of medvedd
medvedd

Please double-check that mount point exists:

file /mnt/warehouse_win
ls -l /mnt

Avatar of techmiss

ASKER

Yes the mount point exists, as I ran the command outside of the script and it worked fine.

Below is by desired mount point.

[root@server /]# ls -l /mnt
total 4
drwxr-xr-x  2 root root 4096 Apr 22 13:59 warehouse_win

Thanks

K
Please post the script. From what I see here this should work. As a test I used the following script:

#!/bin/bash

# Mount the directory
mount -t cifs //192.168.1.50/PDFStorage -o username=jfaubion,password=MyPassWd /mnt/warehouse_win

This mounts with no issues on both Fedora 12 and Centos 5.4. Granted not Red Hat exactly but the closest flavors I had available tonight.

Hi,

Code is below, when I run this script using ./scriptname.sh I now get the message:

": bad interpreter: No such file or directory"

When I run the same mount command at the command line it mounts successfully.

Thanks

K


#!/bin/bash
#mount the directory
mount -t cifs //10.41.5.242/warehouse -o username=warehouse,password=password /mnt/warehouse_win

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of jfaubiontx
jfaubiontx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So did that fix the issue?
Avatar of Julian Parker
did you whittle your script down a lot?

I have to agree with jfaubiontx about the error above, I'd bet you've got ^M chars at the end of the lines.

I'm also wondering if /mnt is mounted by something else before, I only ask because you did not show the interpreter error in your original Q.

Was the second option - script was indeed edited in notepad.

Thanks.