Find the answer to your Linux question:
Results 1 to 2 of 2
I have a script that I am running that copies files from one source folder to a destination folder. The script is in a crontab file it's only function is ...
  1. #1
    Just Joined!
    Join Date
    Feb 2012
    Posts
    1

    cd command in shell script returns: No such file or directory

    I have a script that I am running that copies files from one source folder to a destination folder.

    The script is in a crontab file it's only function is to copy files
    Within the script, I perform a change directory to the /tmp folder and execute the cp command to copy the file

    cd /tmp
    cp cputest_donotremove.txt /apps/opt/archive/tmp/demo/staging/encrypt01.tmp
    cp cputest_donotremove.txt /apps/opt/archive/tmp/demo/staging/encrypt02.tmp

    This is the result:

    [seeuser staging]$ ./movefiles.sh
    : No such file or directory /tmp

    Any idea why the cd command fails? the /tmp directory exists, in the correct case and spelling so that is not the issue. I've also tried
    typing this using UltraEdit, notepad, and even vi editor on the linux box; Gives the same result.

    Why is Linux not able to process the cd statement?

    Thanks,

    Corey

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,096
    The shebang is missing.
    Without it, the program loader doesnt know which interpreter (bash, tcsh, perl, python, ruby, etc) to call with this textfile as argument.

    Use this as the first line:
    Code:
    #!/usr/bin/env bash
    Also: Make sure, that you use unix style line feeds.
    You must always face the curtain with a bow.

Posting Permissions

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