Rechercher dans ce blog

mardi 15 septembre 2009

applescript open ssh window in terminal with specific encoding settings

Je ne suis pas certain du tout que ce script soit tout à fait comme il faut... mais comme je n'ai pas grande idée de comment exactement fonctionne applescript j'ai bidouillé ces deux scripts en glanant ça et là des idées... sans doute y a-t-il une manière plus élégante d'écrire ça... sans doute même des fonctions et des propriétés que j'ignore, mais pour simplement ouvrir 3 fenêtres de terminal avec ssh... du moment que ça marche, c'est bon pour moi.


property commandString : "ssh user@host" -- < Edit this line as desired.


tell application "Terminal" -- Get a free window to run the commandString,

set windowCount to (count of the windows)

--activate

if ((count of windows) is 1) then

close window 1 -- attention, s'il n'y a qu'une seule fenêtre ouverte, elle sera fermée

--tell window 1

-- set miniaturized to true

--end tell

repeat with w from 1 to 3 -- je veux 3 connexions

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

  

--settings 7 = my colors and ISO-8859-1ISO Latin-1 encoding and police 16 pt

tell front window

set zoomed to true

-- Je veux que mes 3 fenêtres soient maximizées et occupent tout l'écran

end tell

end repeat

else

repeat with w from 1 to 3

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

tell front window

set zoomed to true

end tell

end repeat

end if

end tell


*** Autre version, avec trois fenêtres disposées 1 full screen et 2 half screen ***

pour un écran de 1680 x 1050


property commandString : "ssh meteo@mars" -- < Edit this line as desired.


tell application "Terminal" -- Get a free window to run the commandString,

set windowCount to (count of the windows)

activate

if ((count of windows) is 1) then

close window 1

--tell window 1

-- set miniaturized to true

--end tell

repeat with w from 1 to 3

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

tell front window

if w is 1 then

set zoomed to true

else

if w is 2 then

set position to {20, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 0, 820, 975}

else

set position to {850, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 670, 820, 975}

end if

end if

end tell

end repeat

else

repeat with w from 1 to 3

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

tell front window

if w is 1 then

set zoomed to true

else

if w is 2 then

set position to {20, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 0, 820, 975}

else

set position to {850, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 670, 820, 975}

end if

end if

end tell

end repeat

end if

end tell


lundi 14 septembre 2009

vendredi 11 septembre 2009

GRANT ALL PRIVILEGES : MYSQL

Pour donner accès aux dB à un utilisateur :

Se logger comme root dans mysql

mysql -u root mysql -p

au prompt : password

puis

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION;

flush privileges;

Pour vérifier :

SELECT user, host, password FROM user;

à la place de localhost = connection uniquement en local, on peut mettre % pour pouvoir se logger à distance.

jeudi 10 septembre 2009

mysql backup

Les fichiers des db se trouvent (ubuntu 8.04)

/var/lib/mysql/

On peut simplement faire une copie des fichiers mais il faut mettre un lock write avant.

C'est ce que fait le script mysqlhotcopy

Syntaxe :

A exécuter comme root

mysqlhotcopy metar_2009 -u meteo -p '' --addtodest /tmp/mysqlbackup

mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory

--addtodest

Do not rename target directory (if it exists); merely add files to it.

--dryrun, -n

Report actions without performing them.

--method=command

The method for copying files (cp or scp).

--password=password, -ppassword

The password to use when connecting to the server. Note that the password value is not optional for this option, unlike for other MySQL programs. You can use an option file to avoid giving the password on the command line.

--user=user_name, -u user_name

The MySQL user name to use when connecting to the server.

6.1. Database Backups

This section summarizes some general methods for making backups.

Making Backups by Copying Files

MyISAM tables are stored as files, so it is easy to do a backup by copying files. To get a consistent backup, do aLOCK TABLES on the relevant tables, followed by FLUSH TABLES for the tables. See Section 12.4.5, “LOCK TABLES and UNLOCK TABLES Syntax”, and Section 12.5.6.3, “FLUSH Syntax”. You need only a read lock; this allows other clients to continue to query the tables while you are making a copy of the files in the database directory. The FLUSH TABLES statement is needed to ensure that the all active index pages are written to disk before you start the backup.

Making Delimited-Text File Backups

To create a text file containing a table's data, you can use SELECT * INTO OUTFILE 'file_name' FROMtbl_name. The file is created on the MySQL server host, not the client host. For this statement, the output file cannot already exist because allowing files to be overwritten would constitute a security risk. See Section 12.2.8, “SELECT Syntax”. This method works for any kind of data file, but saves only table data, not the table structure.

To reload the output file, use LOAD DATA INFILE or mysqlimport.

Making Backups with mysqldump or mysqlhotcopy

Another technique for backing up a database is to use the mysqldump program or the mysqlhotcopy script.mysqldump is more general because it can back up all kinds of tables. mysqlhotcopy works only with some storage engines. (See Section 4.5.4, “mysqldump — A Database Backup Program”, and Section 4.6.9, “mysqlhotcopy — A Database Backup Program”.)

Create a full backup of your database:

shell> mysqldump --tab=/path/to/some/dir --opt db_name

Or:

shell> mysqlhotcopy db_name /path/to/some/dir

You can also create a binary backup simply by copying all table files (*.frm, *.MYD, and *.MYI files), as long as the server isn't updating anything. The mysqlhotcopy script uses this method. (But note that these methods do not work if your database contains InnoDB tables. InnoDB does not necessarily store table contents in database directories, and mysqlhotcopy works only for MyISAM and ISAM tables.)

For InnoDB tables, it is possible to perform an online backup that takes no locks on tables; see Section 4.5.4, “mysqldump — A Database Backup Program”.

smbpasswd and pdbedit samba

pdbedit remplace smbpasswd pour éditer le fichier smbpasswd.