Hello,
I would like to know how to check if file exists (i need this part with my script)
I tried using google, but haven't found anything that would help.
here is the script I tried to write
I commented the parts that were preventing int from running at all
This script should do the following:
when i plug in my USB device (MP3 player, or flash drive) the script checks if /dev/sda1 exists
if yes, it mounts it on /media/usb (if it exists, else creates this directory).
If /dev/sda1 doesn't exist then it should check if /dev/sdb1 exists and mount it on /media/usb .
now I don't know how to check that.
I tried using
Like in DOS. It didn't work
I thougt this might work
another bad idea
i found this in google, but it doesn't work either.
Can anyone help me with this silly script?
I would like to know how to check if file exists (i need this part with my script)
I tried using google, but haven't found anything that would help.
here is the script I tried to write
Code:
#! /bin/sh ### By Gediminas # 2007 # First USB port echo "Mounting Device" #if -f /dev/sda1 #then #if -d /media/usb #then echo "Already exist" #else sudo mkdir /media/usb #fi sudo mount /dev/sda1 /media/usb kdesu konqueror /media/usb sudo umount /media/usb # Second USB port #elif -f /dev/sdb1 #then #if -d /media/usb #then echo "Already exist" #else sudo mkdir /media/usb #fi sudo mount /dev/sdb1 /media/usb kdesu konqueror /media/usb sudo umount /media/usb #else echo "Device not found" #fi exit
This script should do the following:
when i plug in my USB device (MP3 player, or flash drive) the script checks if /dev/sda1 exists
if yes, it mounts it on /media/usb (if it exists, else creates this directory).
If /dev/sda1 doesn't exist then it should check if /dev/sdb1 exists and mount it on /media/usb .
now I don't know how to check that.
I tried using
Code:
if exist /dev/sda1
Code:
if /dev/sda1
Code:
if /dev/sda1 =! 0
Code:
if -f /dev/sda1
Can anyone help me with this silly script?
Comment