#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    5
    Rep Power
    0

    check to see if file is from other dir.......


    is it possible to test if when running a script that the file the user is attempting to use is from a different folder.

    is the most simple tool grep??

    basically this is the code below

    for file do ls $file | grep '/' > /dev/null 2>&1
    if [ $? -ne 1 ]
    then echo "blah" > &2
    exit 0

    Thing is if the file doesnt exsist then i get 2 error one because error messages dont go through pipes and another one that i have put for that paticular occurance.

    can anyone suggest any other better ways of doing it.

    Thanks Simpson
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    Don't know exactly what you're trying to do. For the 2nd one add a number before $? like so it's always non-empty.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    5
    Rep Power
    0
    basically when people run my script i want to make sure that the files they use for the script is not from another directory, they can only run the script if the files are in the current directory.

    i though if i use grep it could look at the path and make sure there isnt any "/" in the path.

IMN logo majestic logo threadwatch logo seochat tools logo