Find the answer to your Linux question:
Results 1 to 6 of 6
I can't seem to get the following code to give me anything other than "Data not found". I have the target directories in the same directory as the script that ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3

    scritping question

    I can't seem to get the following code to give me anything other than "Data not found". I have the target directories in the same directory as the script that I am running. I know that the error is in the "if" statement, but I can't seem to figure it out. Any suggestions would be greatly appreciated!


    echo "Enter dataset/s to tar and gzip.--> \c"
    read dat
    totsize=0
    mul=0

    if [ ! -f $dat -a $# -eq 0 ]
    then
    echo Data not found, check your entry and resubmit.
    exit
    else

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    $# gives the number of command line arguments.

    Have you pass arguments to your script?

    Regards

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3
    The lines before my if statement are where I input values. It's supposed to be dynamic.

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Quote Originally Posted by Stevenh
    The lines before my if statement are where I input values. It's supposed to be dynamic.
    OK, but that wasn't the question

    Regards

  5. #5
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Make life easier with the bash debugger.

    bash -x your_script_here

    Post the output...

  6. #6
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3
    I found out that what I needed to use was a "-d" not "-f". It works fine now. To answer your other question, Yes, I had passed the arguments to my script. Thank you Franklin52.

    I'll save the debugger for future problems.

Posting Permissions

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