Skip to main content
edited body
Source Link
Vlastimil Burián
  • 31.3k
  • 66
  • 211
  • 358

Below is what I'm attempting to run on my remote machine, and I'm getting 'Unexpected end of file'.

However, if i take the lines and paste them into the CLI, it executes normally.

# if [ -f running.script ] ; then echo 'Script already running.'
> else echo 'Script not running.' ; touch running.script
<ervers_status | awk 'NR==1 {print $3}' | tr -d '\r')
<ervers_status | awk 'NR==2 {print $3}' | tr -d '\r')
> if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
> if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
> if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
> if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
> if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
> if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
> rm running.script
> fi
Script not running.
Sip Server 1 UP
Sip Server 2 IDLE
#sh script.sh
script.sh: line 14: syntax error: unexpected end of file
# cat script.sh
#!/bin/sh
if [ -f running.script ] ; then echo 'Script already running.'
else echo 'Script not running.' ; touch running.script
    sip1=$(cat /var/mand/sipservers_status | awk 'NR==1 {print $3}' | tr -d '\r')
    sip2=$(cat /var/mand/sipservers_status | awk 'NR==2 {print $3}' | tr -d '\r')
    if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
    if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
    if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
    if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
    if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
    if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
    rm running.script
fi
#

I've included the below capture of my NP++ showing exactly what's in the script.

enter image description hereenter image description here

Below is what I'm attempting to run on my remote machine, and I'm getting 'Unexpected end of file'.

However, if i take the lines and paste them into the CLI, it executes normally.

# if [ -f running.script ] ; then echo 'Script already running.'
> else echo 'Script not running.' ; touch running.script
<ervers_status | awk 'NR==1 {print $3}' | tr -d '\r')
<ervers_status | awk 'NR==2 {print $3}' | tr -d '\r')
> if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
> if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
> if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
> if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
> if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
> if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
> rm running.script
> fi
Script not running.
Sip Server 1 UP
Sip Server 2 IDLE
#sh script.sh
script.sh: line 14: syntax error: unexpected end of file
# cat script.sh
#!/bin/sh
if [ -f running.script ] ; then echo 'Script already running.'
else echo 'Script not running.' ; touch running.script
    sip1=$(cat /var/mand/sipservers_status | awk 'NR==1 {print $3}' | tr -d '\r')
    sip2=$(cat /var/mand/sipservers_status | awk 'NR==2 {print $3}' | tr -d '\r')
    if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
    if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
    if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
    if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
    if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
    if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
    rm running.script
fi
#

I've included the below capture of my NP++ showing exactly what's in the script.

enter image description here

Below is what I'm attempting to run on my remote machine, and I'm getting 'Unexpected end of file'.

However, if i take the lines and paste them into the CLI, it executes normally.

# if [ -f running.script ] ; then echo 'Script already running.'
> else echo 'Script not running.' ; touch running.script
<ervers_status | awk 'NR==1 {print $3}' | tr -d '\r')
<ervers_status | awk 'NR==2 {print $3}' | tr -d '\r')
> if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
> if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
> if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
> if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
> if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
> if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
> rm running.script
> fi
Script not running.
Sip Server 1 UP
Sip Server 2 IDLE
#sh script.sh
script.sh: line 14: syntax error: unexpected end of file
# cat script.sh
#!/bin/sh
if [ -f running.script ] ; then echo 'Script already running.'
else echo 'Script not running.' ; touch running.script
    sip1=$(cat /var/mand/sipservers_status | awk 'NR==1 {print $3}' | tr -d '\r')
    sip2=$(cat /var/mand/sipservers_status | awk 'NR==2 {print $3}' | tr -d '\r')
    if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
    if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
    if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
    if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
    if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
    if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
    rm running.script
fi
#

I've included the below capture of my NP++ showing exactly what's in the script.

enter image description here

added 64 characters in body; edited tags
Source Link
Vlastimil Burián
  • 31.3k
  • 66
  • 211
  • 358

Below is what I'm attempting to run on my remote machine, and I'm getting 'Unexpected end of file'.

However, if i take the lines and paste them into the CLI, it executes normally.

# if [ -f running.script ] ; then echo 'Script already running.'
> else echo 'Script not running.' ; touch running.script
<ervers_status | awk 'NR==1 {print $3}' | tr -d '\r')
<ervers_status | awk 'NR==2 {print $3}' | tr -d '\r')
> if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
> if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
> if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
> if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
> if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
> if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
> rm running.script
> fi
Script not running.
Sip Server 1 UP
Sip Server 2 IDLE
#sh script.sh
script.sh: line 14: syntax error: unexpected end of file
# cat script.sh
#!/bin/sh
if [ -f running.script ] ; then echo 'Script already running.'
else echo 'Script not running.' ; touch running.script
    sip1=$(cat /var/mand/sipservers_status | awk 'NR==1 {print $3}' | tr -d '\r')
    sip2=$(cat /var/mand/sipservers_status | awk 'NR==2 {print $3}' | tr -d '\r')
    if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
    if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
    if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
    if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
    if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
    if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
    rm running.script
fi
#

I've included the below capture of my NP++ showing exactly what's in the script.

i.imgur.com/VTJQzPN.pngenter image description here

Below is what I'm attempting to run on my remote machine, and I'm getting 'Unexpected end of file'.

However, if i take the lines and paste them into the CLI, it executes normally.

# if [ -f running.script ] ; then echo 'Script already running.'
> else echo 'Script not running.' ; touch running.script
<ervers_status | awk 'NR==1 {print $3}' | tr -d '\r')
<ervers_status | awk 'NR==2 {print $3}' | tr -d '\r')
> if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
> if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
> if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
> if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
> if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
> if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
> rm running.script
> fi
Script not running.
Sip Server 1 UP
Sip Server 2 IDLE
#sh script.sh
script.sh: line 14: syntax error: unexpected end of file
# cat script.sh
#!/bin/sh
if [ -f running.script ] ; then echo 'Script already running.'
else echo 'Script not running.' ; touch running.script
    sip1=$(cat /var/mand/sipservers_status | awk 'NR==1 {print $3}' | tr -d '\r')
    sip2=$(cat /var/mand/sipservers_status | awk 'NR==2 {print $3}' | tr -d '\r')
    if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
    if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
    if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
    if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
    if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
    if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
    rm running.script
fi
#

I've included the below capture of my NP++ showing exactly what's in the script.

i.imgur.com/VTJQzPN.png

Below is what I'm attempting to run on my remote machine, and I'm getting 'Unexpected end of file'.

However, if i take the lines and paste them into the CLI, it executes normally.

# if [ -f running.script ] ; then echo 'Script already running.'
> else echo 'Script not running.' ; touch running.script
<ervers_status | awk 'NR==1 {print $3}' | tr -d '\r')
<ervers_status | awk 'NR==2 {print $3}' | tr -d '\r')
> if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
> if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
> if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
> if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
> if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
> if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
> rm running.script
> fi
Script not running.
Sip Server 1 UP
Sip Server 2 IDLE
#sh script.sh
script.sh: line 14: syntax error: unexpected end of file
# cat script.sh
#!/bin/sh
if [ -f running.script ] ; then echo 'Script already running.'
else echo 'Script not running.' ; touch running.script
    sip1=$(cat /var/mand/sipservers_status | awk 'NR==1 {print $3}' | tr -d '\r')
    sip2=$(cat /var/mand/sipservers_status | awk 'NR==2 {print $3}' | tr -d '\r')
    if [ "$sip1" = 0 ] ; then echo "Sip Server 1 UP" ; fi
    if [ "$sip1" = 1 ] ; then echo "Sip Server 1 DOWN" ; fi
    if [ "$sip1" = 2 ] ; then echo "Sip Server 1 IDLE" ; fi
    if [ "$sip2" = 0 ] ; then echo "Sip Server 2 UP" ; fi
    if [ "$sip2" = 1 ] ; then echo "Sip Server 2 DOWN" ; fi
    if [ "$sip2" = 2 ] ; then echo "Sip Server 2 IDLE" ; fi
    rm running.script
fi
#

I've included the below capture of my NP++ showing exactly what's in the script.

enter image description here

added 55 characters in body
Source Link

I'm clearly missing something, just don't know whatI've included the below capture of my NP++ showing exactly what's in the script.

i.imgur.com/VTJQzPN.png

I'm clearly missing something, just don't know what.

I've included the below capture of my NP++ showing exactly what's in the script.

i.imgur.com/VTJQzPN.png

Source Link
Loading