bash script with "mount -t cifs" hangs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash script with "mount -t cifs" hangs
# 1  
Old 08-24-2011
bash script with "mount -t cifs" hangs

Dear all,

I have a bash script that mounts a number of samba shares, but one particular mount command makes it hang. Strangely, the same command works when executed directly from the command line:

Code:
sudo mount -t cifs //name-of-share /media/FTPpublic -o username=myname

asks for the password and then mounts the share as expected.
In the script, I have the line:

Code:
sudo mount -t cifs //name-of-share /media/FTPpublic -o username=$usn,password=$usp

where usn and usp are user name and password entered earlier. This works for all other mount commands in the script, but wherever I put the line with this particular share, it just hangs at this point.

Any help will be greatly appreciated.

Cheers
Stan
# 2  
Old 08-24-2011
Try putting $usn and $usp in "quotes", if they have spaces the shell might be splitting them otherwise.

When in doubt, echo the line to make sure it's ending up as what you think it is.

Any relevant messages in dmesg?
# 3  
Old 08-24-2011
bash script with "mount -t cifs" hangs

Thanks for the quick reply! There are no spaces in $usn and $passwd and the same format works for the other mount commands in the script.
dmesg records the following error messages, but only after I stop the hanging script by CTRL-C:
Code:
[10729.713718] CIFS VFS: Error connecting to socket. Aborting operation
[10729.713743] CIFS VFS: cifs_mount failed w/return code = -512

A quick google search did not reveal anything relevant for this error code, but since it only happens after aborting the script, this is probably not the culprit.
# 4  
Old 08-24-2011
Try quoting them anyway.

Have you tried echoing the line, to make sure it really ended up the way you thought it would?
# 5  
Old 08-24-2011
I was thinking about echoing the line and then pasting it into a terminal window, but then my password would be displayed in clear text and saved in the terminal history. Is there a way to avoid that?
# 6  
Old 08-24-2011
I don't mean echoing it for copy-paste -- there's no good reason a line that works when typed into your shell shouldn't work in a script. I just mean printing the line to see if you notice any glaring errors in it -- perhaps the password contained special characters or something that the script mangled, your variables had unexpected spaces or newlines in them, and so forth.

But running it in the shell would be a decent test too.

How to clear your history file depends on what your shell is, what is it?

[edit] You have bash, so rm ~/.bash_history should delete your history. Beware that this file is only updated AFTER you logout of your shell, so don't delete it in the same session: do the operation, logout, login, then delete it.

Last edited by Corona688; 08-24-2011 at 01:22 PM..
# 7  
Old 08-24-2011
It's a unix shell in gnome-terminal.
Suddenly the mount command does not seem to work from the terminal, either. I have a suspicion, but need to check it out. Will report back when done.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Explaining behaviour of sudo bash "$0" "$@";

I've found this script part on the stackoverflow: if ; then sudo bash "$0" "$@"; exit "$?"; fi I realized that sudo bash "$0" "$@"; is the only needed for me. But the strange thing happens when I move this line outside the IF statement: sudo bash "$0" "$@"; stops the... (9 Replies)
Discussion started by: boqsc
9 Replies

3. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

Hello, :) I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output : #!/bin/bash # PATHS HOME_BACKUP="/home/backup" HOME_SCRIPT="/home/scripts/test/backup_server" TARGET="/var/www" # DATE DATE_Ymd=$(date +%Y-%m-%d) #... (1 Reply)
Discussion started by: Arnaudh78
1 Replies

4. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

5. Shell Programming and Scripting

Bash script fails with "function: not found" error

Hello everyone, I am having problems figuring this out. This script below is supposed to create a list of file names with their "md5sum", in a file "lib-list.txt" When I run it "sh component-list.sh " I get this:component-list.sh: 4: component-list.sh: function: not found component-list.sh:... (4 Replies)
Discussion started by: joemb
4 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

8. UNIX for Dummies Questions & Answers

BASH: getting a script to "do" what's after "done"

The script: #!/bin/bash SAVEIFS=$IFS IFS=$(echo -en "\n\b") w=$(ls *.jpg | wc -l) x=1 z=0 for file in $(ls *.jpg); do echo "Evaluating #$x of $w, $file..." sleep 0.2s MANY=$(exiv2 -g Exif.Image.Software $file) if ] then exiv2 -M"del Exif.Image.Software" modify $file echo... (8 Replies)
Discussion started by: SilversleevesX
8 Replies

9. UNIX for Dummies Questions & Answers

Alias, function or script (bash) to "revert" cd command?

In all of my brief and superficial experience with Unix or Linux, the one curious and consistent thing has been that 'cd ./' (back up one directory level) has done absolutely nothing in any of them. Now I understand that, at least for bash, 'cd ./' appears to have been substituted by 'cd ..' Am... (1 Reply)
Discussion started by: SilversleevesX
1 Replies

10. Shell Programming and Scripting

Why generate "ash and bash" different output for same bash script?

Hi, For my bash script, terminal with bash is generate an OK output and program works right. already, terminal with ash have "line 48: syntax error: Bad substitution" output and program don't work. :confused: (0 Replies)
Discussion started by: s. murat
0 Replies
Login or Register to Ask a Question