Page 2 of 5 FirstFirst 1234 ... LastLast
Results 11 to 20 of 44

Thread: Sync Script

  1. #11
    Join Date
    May 2010
    Location
    Here
    Beans
    1,297
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Sync Script

    Quote Originally Posted by Forbees View Post
    whats the "fi" at the end for? is that a typo or needed lol
    You are not alone! I was thinking the same thing a while ago!
    It just says that it is the end of the if statement.

  2. #12
    Join Date
    Sep 2008
    Location
    metro detriot area
    Beans
    308
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Sync Script

    that variable isn't working . . . .

  3. #13
    Join Date
    May 2010
    Location
    Here
    Beans
    1,297
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Sync Script

    What variable isn't working?

  4. #14
    Join Date
    Sep 2008
    Location
    your profile
    Beans
    632
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Sync Script

    $? I believe he is referring to. Is it really the variable that isn't working? Try running the mount command in a terminal followed by "echo $?"

    My suspicion is that you have a typo/error in the way your script is set up. Post it please (exactly).
    Last edited by Zorgoth; July 19th, 2010 at 05:28 PM.

  5. #15
    Join Date
    May 2010
    Location
    Here
    Beans
    1,297
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Sync Script

    You can test the ? variable like this:
    Test 1:
    Code:
    echo hello
    echo $?
    It should output 0

    Test 2:
    Code:
    hffees
    echo $?
    It should output something like 127

    Both of the tests should work.

  6. #16
    Join Date
    Sep 2008
    Location
    metro detriot area
    Beans
    308
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Sync Script

    okay, the echo output did say $?=0 . . .

    when i run the script it closes so fast i can't read the error, but i could have sworn i saw something to do with $? . . .

    and awesome . . . for some reason it didn't unmount before deleting the directory so i just lost 60gig of music :-/

    so you can yell at me since i obviously did something wrong lol
    Code:
    sudo mkdir /media/ServerMusic/
    sudo mount -t cifs -o user=Justin,password=****** //192.168.1.108/Public-3/Music/ /media/ServerMusic
    if [[0=$?]]
    then
    rsync -v -P --delete --min-size=10000 ir iu /media/ServerMusic/ /home/forbees/Music
    sudo umount /media/ServerMusic/
    sudo rm -r /media/ServerMusic/
    echo "sync successful"
    else
    sudo umount /media/ServerMusic/
    sudo rm -r /media/ServerMusic/
    echo "mount failed"
    fi

  7. #17
    Join Date
    Sep 2008
    Location
    metro detriot area
    Beans
    308
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Sync Script

    and awesome . . . for some reason it didn't unmount before deleting the directory so i just lost 60gig of music :-/
    the majority of it was still on my netbook thankfully . . so now i just have to go through and find missing files(certain tracks from albums are still gones :-/ )

  8. #18
    Join Date
    Sep 2008
    Location
    your profile
    Beans
    632
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Sync Script

    You failed to include the spaces I mentioned in the if expression.

    You have to say
    Code:
    if [[ $? == 0 ]]
    rather than
    Code:
    if [[$?==0]]
    Don't ask me why; I don't get it either.

    OH - YOU ALSO NEED 2 EQUALS SIGNS.

    This is ordinary in programming. = is assignment, == is comparison.

    I hope your music is OK; in the future when writing important scripts be sure to test every component before using them in practice.

  9. #19
    Join Date
    Sep 2008
    Location
    your profile
    Beans
    632
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Sync Script

    Also, I would recommend that you make /media/ServerMusic an empty directory when not mounted, and then rather than that dangerous "rm -r" you could use "rmdir", which will fail if there are files in the directory.

  10. #20
    Join Date
    May 2010
    Location
    Here
    Beans
    1,297
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Sync Script

    Quote Originally Posted by Forbees View Post
    okay, the echo output did say $?=0 . . .

    when i run the script it closes so fast i can't read the error, but i could have sworn i saw something to do with $? . . .

    and awesome . . . for some reason it didn't unmount before deleting the directory so i just lost 60gig of music :-/

    so you can yell at me since i obviously did something wrong lol
    Code:
    sudo mkdir /media/ServerMusic/
    sudo mount -t cifs -o user=Justin,password=****** //192.168.1.108/Public-3/Music/ /media/ServerMusic
    if [[0=$?]]
    then
    rsync -v -P --delete --min-size=10000 ir iu /media/ServerMusic/ /home/forbees/Music
    sudo umount /media/ServerMusic/
    sudo rm -r /media/ServerMusic/
    echo "sync successful"
    else
    sudo umount /media/ServerMusic/
    sudo rm -r /media/ServerMusic/
    echo "mount failed"
    fi
    Code:
    sudo mkdir /media/ServerMusic/
    sudo mount -t cifs -o user=Justin,password=****** //192.168.1.108/Public-3/Music/ /media/ServerMusic
    if [[$? == 0]]
    then
    rsync -v -P --delete --min-size=10000 ir iu /media/ServerMusic/ /home/forbees/Music
    sudo umount /media/ServerMusic/
    sudo rm -r /media/ServerMusic/
    echo "sync successful"
    else
    sudo umount /media/ServerMusic/
    sudo rm -r /media/ServerMusic/
    echo "mount failed"
    fi

Page 2 of 5 FirstFirst 1234 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •