Solved Script copy from one machine to another machine does not run !

vic

New Member


Messages: 6

I am newbie, I am missing something...

I have simple script saved in file /rc.d/initialize one one freebsd machine with permission
Code:
-r-xr-xr-x  1 root  wheel  442 May 19 21:51 initialize
When I copy this file to another machine ( gui file explorer ) ( file permission on new machines are same when I run ls -l ) it does not work give me error message.
When I try to run.
Code:
/etc/rc.d/initialize start
Command not found message
ls -l on new machine
Code:
-r-xr-xr-x  1 root  wheel  442 May 19 21:51 initialize   - On new machine
If I delete old file and recreate new file on new machine with with text editor and make it executable it works.

/rc.d/initialize
Code:
!/bin/sh
. /etc/rc.subr
name="initialize"
start_cmd="${name}_start"
stop_cmd=":"
initialize_start()
{
        if [ -f /etc/initialize ]; then
        echo "Default password set !"
                sh -c "pwd_mkdb -p /etc/master.passwd"\
        echo "Save all Files for /CFG"
                sh -c "yes | sh /root/save_cfg"
        sh -c "rm /etc/initialize"
    fi
}
load_rc_config $name
run_rc_command "$1"
Any help really appreciate.
 
OP
V

vic

New Member


Messages: 6

Mr. SirDice

It is my bad. It is actually #!/bin/sh, it is cut and paste error.

Thanks

Vic
 
OP
V

vic

New Member


Messages: 6

Run on the copied file file initialize , post output.
Hello VladiBG:
Output is.

initialize: POSIX shell script, ASCII text executable, with CRLF line terminators

Thanks for your help.

Vic
 

T-Daemon

Aspiring Daemon

Reaction score: 367
Messages: 866

initialize: POSIX shell script, ASCII text executable, with CRLF line terminators
Open the copied file with vi(1) ( /usr/bin/vi, no other editor ). I bet you will find in the text formatting characters not belonging there.

Here some info:

/etc/rc.d/initialize
Side-note: It is suggested, rc(8) scripts not belonging to the system should be placed in /usr/local/etc/rc.d/ .
 
  • Thanks
Reactions: vic
OP
V

vic

New Member


Messages: 6

Mr. T-Daemon,

You are right. When I compare two output CRLF was the problem. I found the bug now it is working.

initialize: POSIX shell script, ASCII text executable, with CRLF line terminators.

Thanks for everyone's help.

Vic
 
Top