Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    creating a script file... (unix/linux and VI editor)

    need help with writing a script called DEL. However, instead of deleteing it moves the user specified directory called deleted.files in the users homes directory. The DEL script file should create the "deleted.files" directory if it does not already exist. Need to make an IF statement to determin if the ~/deleted.files directory exists and only create it if it doesn't. can anybody assist me on this?????

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: creating a script file... (unix/linux and VI editor)

    What scripting language are you using on your *nix platform. Perl?

  3. #3
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI editor)

    im using vi editor here is ehat I have so far....
    #!/bin/ksh

    umask 666
    set path=/home/jvanosky
    echo "Where are you? Are you in the correct directory?"
    rm -r deleted.files
    mkdir /home/jvanosky/deleted.files
    chmod u+rwx /home/jvanosky/deleted.files
    mv /home/jvanosky/scripts/*.!$ /home/jvanosky/deleted.files

    echo "del file"
    if [-f $deleted.files]
    then
    echo The contents of $deleted.files:
    more $deleted.files
    else
    echo $deleted.files does not exist
    fi


    is there a better way to do this?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: creating a script file... (unix/linux and VI editor)

    I don't want to discourage you from posting in the Lounge, but Unix is not really a well-covered subject. This question does not belong in the VB/VBA forum where you originally posted it; I moved it to Other OSes.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newark, New Jersey, USA
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI e

    Hold on, I can help with this.... gimme a sec...
    Mike Wolfman
    Jack of all, Master of none
    Bow before me, for I am root.
    <IMG SRC=http://www.wopr.com/w3tfiles/112673-wolfsig.jpg>

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newark, New Jersey, USA
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI e

    what distro are you using??? Why /bin/ksh? I mean, its fine, just curious.
    Mike Wolfman
    Jack of all, Master of none
    Bow before me, for I am root.
    <IMG SRC=http://www.wopr.com/w3tfiles/112673-wolfsig.jpg>

  7. #7
    2 Star Lounger
    Join Date
    Apr 2004
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI editor)

    so can anybody actually show me what to do?

  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newark, New Jersey, USA
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI e

    What distro are you using??
    Mike Wolfman
    Jack of all, Master of none
    Bow before me, for I am root.
    <IMG SRC=http://www.wopr.com/w3tfiles/112673-wolfsig.jpg>

  9. #9
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newark, New Jersey, USA
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI e

    Why are you removing the delete/.files directory on line 6?

    Try this:

    #!/bin/sh



    mkdir -p $HOME/deleted.files 2>/dev/null

    mv $* $HOME/deleted.files

    the first line create the directory (and parent if needed and if its there, it returns any error to /dewv/nul cuz, I dont care

    then it moves the directory you specify after DEL (del <dir>) to delete files...

    Is this what you were looking for?
    Mike Wolfman
    Jack of all, Master of none
    Bow before me, for I am root.
    <IMG SRC=http://www.wopr.com/w3tfiles/112673-wolfsig.jpg>

  10. #10
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newark, New Jersey, USA
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: creating a script file... (unix/linux and VI e

    did this help at all?
    Mike Wolfman
    Jack of all, Master of none
    Bow before me, for I am root.
    <IMG SRC=http://www.wopr.com/w3tfiles/112673-wolfsig.jpg>

Posting Permissions

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