LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2005, 05:29 AM   #1
allididntwantto
LQ Newbie
 
Registered: Apr 2005
Posts: 3

Rep: Reputation: 0
Shell script newbie needs help!


Hi,

I'm trying to script a very basic shell script that tars a directory, does a mount of a network share on my Windows box and then copies across the tar archive. It all works fine when I'm not using the if statement, but I want to use the if statement to check if the mount of the network share has been successful, so it doesn't attempt to copy the file if it hasn't mounted the share. How can I do this?

Here's my script at the moment...

Code:
#!/bin/sh

# Change to snapshots directory
cd /.snapshots/

# Tar & GZip the most recent backup
tar -czvf shimmy.backup.tar.gz hourly.0/

# Move the backup archive to SIMON
if [ `mount -t smbfs -o rw,guest "//SIMON/Archives & Backups" "/mnt/backup/"` ]; then
        mv /.snapshots/shimmy.backup.tar.gz /mnt/backup/SHIMMY/
        umount /mnt/backup/
        echo "Successfully copied backup archive"
else
        echo "Error copying backup archive"
fi
TIA for your help!

Simon Plenderleith
 
Old 04-21-2005, 05:36 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Try replacing
Code:
if [ `mount -t smbfs -o rw,guest "//SIMON/Archives & Backups" "/mnt/backup/"` ]
by
Code:
if mount -t smbfs -o rw,guest "//SIMON/Archives & Backups" "/mnt/backup/"

Last edited by jlliagre; 04-21-2005 at 05:42 AM.
 
Old 04-21-2005, 05:53 AM   #3
allididntwantto
LQ Newbie
 
Registered: Apr 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Perfect, thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
newbie help on small shell script ripcurl Programming 5 09-20-2005 03:17 PM
veprory simple but frustrating for a newbie shell script question marigb Linux - Newbie 11 04-28-2004 12:11 PM
shell script newbie question yoshi95 Programming 1 03-11-2004 02:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration