Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 23 Oct 2018, 06:01
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Mount/umount cifs
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [6 Posts]  
Author Message
willithepuppy

Joined: 10 Mar 2018
Posts: 22

PostPosted: Fri 16 Mar 2018, 16:28    Post subject:  Mount/umount cifs  

Oh my, the forum runs like a snail today

Unfortunately I am an absolute noob in Puppy script.
I have written two scripts. They will connect and unconnect my external hard drive.
For security, the script should unmount the disk if it is already mounted and then reconnect.

First script look like this

#/bin/bash
#if already mounted unmount
umount -a -t cifs -l
sleep 0.3
#reconnect
mount.cifs //192.168.1.107/HDD1 /root/Server -o username="root",password=""
sleep 0.3
rox /root/Server/BT/0_Filme

The second script is

#!/bin/bash
umount -a -t cifs -l

Everything works wonderfully. But of course I get in the first script (mount) an error message if the disk is not mounted yet.

I think the command should look something like this

#/bin/bash
#if already mounted unmount
If mounted
umount -a -t cifs -l
sleep 0.3
else

#connect/reconnect
mount.cifs //192.168.1.107/HDD1 /root/Server -o username="root",password=""
sleep 0.3
rox /root/Server/BT/0_Filme
endif

but this is not sciptlike Puppy.

How is it correct?
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 5161
Location: Ontario

PostPosted: Sat 17 Mar 2018, 13:15    Post subject:  

I believe your question is related to checking if a share is mounted.

Normally you can do this by typing 'df' in terminal but you want to
do it automatically with a script.

You should read this page to find how to automatically find the name of a share

http://www.murga-linux.com/puppy/viewtopic.php?t=112744

I put the final code in my fatdog_connect.sh script in
raspberry pi2 software.
http://murga-linux.com/puppy/viewtopic.php?t=106573
_____________________________________________
Back to top
View user's profile Send private message 
jafadmin

Joined: 19 Mar 2009
Posts: 854

PostPosted: Sat 17 Mar 2018, 15:23    Post subject:  

Code:

#!/bin/bash

mntPt="root/Server"

IsMounted=$(mount | grep $mntPt)  # check for our mount point ..

if [ ! -z "$IsMounted" ] # String is not blank, so ..

   then echo "$mntPt exists"

  else  # then it is blank

   echo "No $mntPt"
fi
Back to top
View user's profile Send private message 
willithepuppy

Joined: 10 Mar 2018
Posts: 22

PostPosted: Sat 17 Mar 2018, 15:43    Post subject:  

Thanks for your replies. But I had to learn more of the syntax of bash commands.

A useful site I've found here

https://ss64.com/bash/

The Rest is try and error. As I see, it is similar to Basic.

And the brain is also used again. That's the most important thing.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 5161
Location: Ontario

PostPosted: Sat 17 Mar 2018, 15:58    Post subject:  

If you're new to bash programming then try
Advanced Bash guide
http://murga-linux.com/puppy/viewtopic.php?t=80501
_________________________________________
Back to top
View user's profile Send private message 
willithepuppy

Joined: 10 Mar 2018
Posts: 22

PostPosted: Sat 17 Mar 2018, 16:30    Post subject:  

Very Happy Very Happy Very Happy Many thanks.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [6 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0713s ][ Queries: 13 (0.0221s) ][ GZIP on ]