Friday, 14 June 2013

Unix Commands And Info

Switch to 'root' User in SUDO

Type:
sudo su -

Prompt should change to reflect the fact you're now logged in as root.

If the following text appears, you don't have root access:



Email a File from Unix

To email a binary/data file from Unix use:
uuencode <filename> <name-to-call-attachment> | mail -s "Subject" <email address>

If uuencode isn't available the contents of a text file can be emailed from Unix:
mail -s "Subject" user@example.com(Note: The contents of the file appears in the body of the email message, not as an attachment)


Search for Files by Contents

To find a file based on its contents in Unix:
find . -name "*.txt" -exec grep -il "hello" {} \;

To scan all files in the current folder for particular text and return the filename:
grep -il "hello"
('i' = ignore case, 'l' = return file names of matches)



Find files and Delete Them

The following command finds files named 'trash' and then deletes them:
find . -name "trash" -exec rm {}\;



Find a file By Date

To find a file based on its date (in this case more than 365 days) and move it:
find . -mtime +365d -exec mv {} /new/destination/folder \;



Copy Hidden Files in Unix


The following command copies any hidden files (files starting with full stop, dot, '.') followed by any letter or number:

cp /path/to/source/.[a-zA-Z0-9]* /path/to/target/




Sort Directory Listing

(Tested on AIX)

To sort a directory listing in Unix:
ls -l | sort +4 -rn

Sorts the list by column 4 (file size) in reverse order (smallest files listed last).


See Who Is or Was on a Server

Type: last | more


Create Softlink (Symbolic link)

ln -s <destination folder> <alias>

The '-s' switch is required to link across filesystems.
More info here:
http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.cmds%2Fdoc%2Faixcmds3%2Fln.htm

Thursday, 13 June 2013

Register Content Server/SAP MaxDB In LMDB/SMSY

How To Register a Content Server/SAP MaxDB in LMDB/SMSY

(Info taken from SAP note 1794004)

Assume Solution Manager Diagnostic agent and Host Agent are installed on server. Host Agent needs to be at least patch 143.

Find Location of Database Tools Path

On Windows, open a command prompt and change directory to C:\Program Files\SAP\hostctrl\exe

Run the following command:
saphostctrl.exe -host <Content Server host> -user sapadm - -dbname <DB SID> -dbtype ada -function GetDatabaseProperties -dbuser <db user ID> -dbpass <db user password>

Enter password for sapadm user.

Locate line saying Database/DatabaseToolsPath=<Path>




Set Connection Details

Run the following command:
saphostctrl.exe -host <DB hostname> -user sapadm - -function ExecuteOperation -name SetupMaxDBCredentials SID=<DB SID> DatabaseToolsPath=<Path> USERNAME=<DB user ID> PASSWORD=<DB user password>

Enter password for sapadm user


If the line "FATAL: Close xuser entry failed:" appears in the reponse carry out the steps below:

  • Enter the following line to register a user:
  • xuser -u <DB user>,<Password> -d <DB SID> -n <DB hostname>
  • Enter the following line to ensure the user details have been saved:
  • xuser list
  • Re-run the previous saphostctrl command to set the connection details.



Test The Connection 

Enter the following command:
saphostctrl.exe -host <DB hostname> -user sapadm - -dbname <DB SID> -dbtype ada -function GetDatabaseStatus

Enter password for sapadm user



LMDB and SMSY

After restarting the host agent service the details of the Content Server or SAP MaxDB will be pushed to the LMDB of the configured SMD Agent.

The database's details will be visible in LMDB/SMSY after a few minutes.