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?
Mount/umount cifs
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
_____________________________________________
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
_____________________________________________
Code: Select all
#!/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
-
- Posts: 31
- Joined: Sat 10 Mar 2018, 19:57
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.
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.
If you're new to bash programming then try
Advanced Bash guide
http://murga-linux.com/puppy/viewtopic.php?t=80501
_________________________________________
Advanced Bash guide
http://murga-linux.com/puppy/viewtopic.php?t=80501
_________________________________________