Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] How to create a *.sh SCRIPT file

Featured Replies

Hello,

 

how can i create a *.sh file?

I´m a linux newbie & my english is verry rusty, because i´m a german user.

 

I tried a few times to copy and paste text to a wordpad editor for a s3 sleep script.

On bootup unraid says "bad interpreter ect ect..."

 

Google says to use a notepad++ and than save the file as an *.sh with a sh structure.

 

When i copied to unraid, i log in on telnet and type chmod +x s3.sh to make it executable.

Then reboot.

On bootup unraid say´s "bad interpreter ect ect...".

 

Where are my mistakes?

What is the easy´s way to make a script?

What are the contents you put in this script?

 

You likely have something messed up on the first few lines of the file.

Also do yourself a favor and check your script with the mc command because I noticed sometimes you will fined a ^M in your code if it isn't saved right.

 

I had the same problem a few nights ago and it made me crazy until I realized it was just because there was some hidden characters.

  • Author

What are the contents you put in this script?

 

The S3 Sleep script...

 

----------------------------------------------

#!/bin/bash

 

drives="/dev/sda /dev/sdb"

timeout=5

 

 

count=5

while [ 1 ]

do

  hdparm -C $drives | grep -q active

  if [ $? -eq 1 ]

  then

    count=$[$count-1]

  else

    count=$timeout

  fi

  if [ $count -le 0 ]

  then

    # Do pre-sleep activities

    sleep 5

 

    # Go to sleep

    echo 3 > /proc/acpi/sleep

 

    # Do post-sleep activities

    # Force a DHCP renewal (shouldn't be used for static-ip boxes)

    /sbin/dhcpcd -n

    sleep 5

 

    count=$timeout

  fi

  # Wait a minute

  echo COUNT $count

  sleep 60

done

-----------------------------------------------------------------------

 

What are the contents you put in this script?

 

The S3 Sleep script...

 

----------------------------------------------

#!/bin/bash

 

drives="/dev/sda /dev/sdb"

timeout=5

 

 

count=5

while [ 1 ]

do

  hdparm -C $drives | grep -q active

  if [ $? -eq 1 ]

  then

    count=$[$count-1]

  else

    count=$timeout

  fi

  if [ $count -le 0 ]

  then

    # Do pre-sleep activities

    sleep 5

 

    # Go to sleep

    echo 3 > /proc/acpi/sleep

 

    # Do post-sleep activities

    # Force a DHCP renewal (shouldn't be used for static-ip boxes)

    /sbin/dhcpcd -n

    sleep 5

 

    count=$timeout

  fi

  # Wait a minute

  echo COUNT $count

  sleep 60

done

-----------------------------------------------------------------------

 

Odds are good you have carriage returns at the ends of the lines and the server is looking for "/bin/bash^M" which does not exist.
  • Author

I have download these text from this forum.

 

I copy and paste it to notepad++ and save it to s3.sh

 

What should i do with script text from this forum to make it executable?

 

What can i do? I´m a linux newbie.

 

Where can i read step by step instructions how to do?

 

It makes me want to tear my hair out! :o  ???

 

 

 

 

  • Author

No one?  >:(

 

With the fromdos -a comand ?

 

i find on google :

 

"Always convert. If converting from DOS to Unix, this option will cause the program to remove ALL carriage returns. The default is to remove carriage returns only if they are followed by line feeds. If converting from Unix to DOS, this option will cause the program to convert ALL linefeeds to carriage return pairs. The default is to convert linefeeds only if they are not already preceded by a carriage return."

 

On Example: fromdos -a s3.sh?

Must i type this command in the go file before the s3.sh starts?

Or must i type fromdos -a s3.sh command on telnet, then reboot, ONE TIME (saveproof),or every time before unraid starts?

 

Please dont forgett, i am a linux / unraid rookie...

My solution was to do all my editing in "vi" which is native to the OS.

 

There are a number of text editor available, my favourite being vi. Now I am cheating since I us vi at my job, and have for years, but it does remove all chance of messing things up doing 'conversions'.

 

There are other options, and the web is a rich resource to find information about the alternative text editors.

 

This is kind of a 'when in Rome...' solution, but you may find it a good one. If you are ready to dive into shell scripting so early in your unRAID experience then you must be ready for vi also.  ;)

 

Hope this helps.

 

Bruce

Open a telnet session to your server and use the command "mc" to browse through your directory structure.

 

Go to the location of your script and press "F4" to edit it. Press "F12" and choose "Linux Format (LF)".

 

File is saved now in the correct format.

  • Author

Yieppie!!!

 

;D ;D ;D ;D

 

With the mc command on telnet F4 & F12 it works fine.

On bootup i have no error messages from Unraid!

 

Now i must look if the scripts works fine...

 

Big Thanks !!!

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.