script creation questions

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
emorrp1

Re: script creation questions

Post by emorrp1 »

I can help you with basic script creation, just not quite sure how you'd get it to do what you want over ssh. I assume you're familiar with the terminal, which by default uses the bash shell environment for you to type in your commands. A bash script has several properties:

1) the file is executable, use

Code: Select all

chmod u+x myscript
2) the first line tells you what program will run it, in this case the shell:

Code: Select all

#!/bin/sh
3) the rest of the file contains a list of commands to run, one per line e.g:

Code: Select all

ls -l ~/Documents
echo "shameless plug"
apt-cache show mintupload
touch temp.txt
echo "hello world!" >> temp.txt
cat temp.txt
rm temp.txt
to run the script:

Code: Select all

./myscript
To learn more, google for "shell scripting"
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Beginner Questions”