Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Help with executing scripts
-
- Posts: 4
- Joined: 2009-12-19 09:14
Help with executing scripts
Hi all,
New Debian user here (moved from Ubuntu). I'm still farily new to Linux and need help understanding how scripts work.
I have a fairly fresh install of Debian 5 and trying to run a script:
script filename: mysql-cron-backup-script
--BOF--
#!/bin/sh
/usr/bin/mysqldump -uUSERNAME -pPASSWORD my_db_name > my_db_name.sql
--EOF--
When I type in "mysql-cron-backup-script" in the command line, it returns:
-bash: mysql-cron-backup-script: command not found
Is there something I'm doing wrong or didn't install?
New Debian user here (moved from Ubuntu). I'm still farily new to Linux and need help understanding how scripts work.
I have a fairly fresh install of Debian 5 and trying to run a script:
script filename: mysql-cron-backup-script
--BOF--
#!/bin/sh
/usr/bin/mysqldump -uUSERNAME -pPASSWORD my_db_name > my_db_name.sql
--EOF--
When I type in "mysql-cron-backup-script" in the command line, it returns:
-bash: mysql-cron-backup-script: command not found
Is there something I'm doing wrong or didn't install?
Re: Help with executing scripts
First make sure that the script is executable:
Secondly make sure that you either give direct path to the script or if you are in the same directory where the script is, put in front of it.
Code: Select all
chmod 744 mysql-cron-backup-script
Code: Select all
./
-
- Posts: 4
- Joined: 2009-12-19 09:14
Re: Help with executing scripts
You have your raw password for mysql in that script, you should not be using 744 permissions. 700 would be more appropriate.
Pantek, Inc. - http://www.pantek.com/ - info@pantek.com
+1-877-LINUX-FIX - Expert Open Source Technical Support
+1-877-LINUX-FIX - Expert Open Source Technical Support
Re: Help with executing scripts
+1, you should always use the least possible permissions in any situation. For a good primer on what linux permissions are, and how they work try http://www.tuxfiles.org/linuxhelp/filepermissions.htmlrweaver wrote:You have your raw password for mysql in that script, you should not be using 744 permissions. 700 would be more appropriate.
Re: Help with executing scripts
Good points rweaver and cnoyes! I didn't take those things into account carefully enough in this case. In general, it's a good thing however to show the script to others to let them learn if one like to do so.
Re: Help with executing scripts
His point wasn't that you posted your script here, it was that you have your raw password in that script, and don't have it locked down on your system.obeliks wrote:Good points rweaver and cnoyes! I didn't take those things into account carefully enough in this case. In general, it's a good thing however to show the script to others to let them learn if one like to do so.
Re: Help with executing scripts
If you use a lot of custom scripts, it is a good idea to add the directory containing those scripts to your $PATH environment variable.
For example, I keep my scripts in $HOME/bin. To add that directory to my $PATH, I put the following line in my shell's rc file:
For example, I keep my scripts in $HOME/bin. To add that directory to my $PATH, I put the following line in my shell's rc file:
Code: Select all
PATH=$HOME/bin:"${PATH}"
export PATH
Re: Help with executing scripts
Ouch, misunderstanding. My native language is not English, maybe it was because of that. I'll try it again.cnoyes wrote:His point wasn't that you posted your script here, it was that you have your raw password in that script, and don't have it locked down on your system.obeliks wrote:Good points rweaver and cnoyes! I didn't take those things into account carefully enough in this case. In general, it's a good thing however to show the script to others to let them learn if one like to do so.
What I meant was that in general it's a good thing to show a script to other users who use your linux system (not here at the forum) and let them to view the script in case they want to learn something about it. Of course if the script contains personal or system critical data, permissions should be set accordingly. I'm sorry about the confusion.
Re: Help with executing scripts
Pretty much any script with a password in it should NOT be system viewable by anyone but you.
Another simple solution would be to source a ~/.mysql_backup file which had the variables set then reference them as variables in the script, that way the 744 permission wouldn't be a danger.
Of course on the otherside of that everytime it runs your password is viewable to everyone on the system who does a ps auxw
Another simple solution would be to source a ~/.mysql_backup file which had the variables set then reference them as variables in the script, that way the 744 permission wouldn't be a danger.
Of course on the otherside of that everytime it runs your password is viewable to everyone on the system who does a ps auxw
Pantek, Inc. - http://www.pantek.com/ - info@pantek.com
+1-877-LINUX-FIX - Expert Open Source Technical Support
+1-877-LINUX-FIX - Expert Open Source Technical Support
Re: Help with executing scripts
One idea is to put the password in a script that's locked down from reading from other users and read that script from the general script that is available to other people to read (if that's what you want). This way you can keep one script viewable and editable by normal user and have the password in a file that can be edited only by root and read only by the user you want.
By the way "./" is simply a shortcut to "current folder" you should be able to run the script by specifying the full path, like /home/username/scriptname, you can't execute it just by typing "scriptname" because that folder is not in the PATH variable.
By the way "./" is simply a shortcut to "current folder" you should be able to run the script by specifying the full path, like /home/username/scriptname, you can't execute it just by typing "scriptname" because that folder is not in the PATH variable.
Ubuntu hate is a mental derangement.