Command line and batch files Molekular Phylogenetics Practical
2 1.1 The command line Alternative to the graphical user interface (GUI) of an operating system Advantages: Commands can be saved for repeated use One program is able to execute other programs Experienced users can perform some tasks faster than with the GUI Drawbacks: Commands and options have to be known by the user (or displayed in a more time-consuming way than in the GUI)
1.2 Usage 3 An input consists of a command and a list of parameters. Command: Name of an executable file (e.g. winword.exe ) Standard command (e.g. cd for change directory) Parameter list: Separated by spaces Provide further information to the executed application e.g. the name of a file to opened with the application Befehl abgetrennt durch Leerzeichen Parameter
1.3 Working directory 4 The current working directory is displayed in front of the input cursor Files in there can be referenced without the full path The command cd changes the working directory command path relative to the current working directoty ( C:\ ) as the only parameter Changed working directory
1.4 Specifiying paths (1) 5 File locations (as commands or parameters) can be specified in different ways: Application and document are both located in the current working directory (relative paths can be used for both) Application is in the working directory, the document is referenced by a relative path.. means one level upwards
1.4 Specifiying paths (2) 6 Application in the current working directory, document referenced by an absolute path Application referenced by an absolute path, document in the current working directory Since the path to the application contains spaces, is has to be put in quotation marks Otherwise C:\Program would be the command and there would be 4 parameters: Files (x86)\editoren\microsoft Office\Office14\winword.exe Dokument.docx Of course is is always possible to specify application and dokument with absolute paths
1.5 Important commands cd <path> dir del <path> md <name> rd <path> copy <source> <target> Copies a file move <source> <target> Moves a file exit Changes the working directory Lists the contents of the working directory Deletes the specified file (or all files in the specified folder) Creates a new directory Deletes the specified directory Terminates the command line session (The same effect as closing the command line window) 7
1.6 Batch files 8 Expressions for the command line can also be saved in text files Repeated tasks can be saved and do have to retyped every time Files have the extension bat Every line in the file contains one expression (consisting of a command and possible parameters) Example: Sets the working directory to the Documents of the user BenStoever and starts Word To execute a batch file simple type its name into the command line (or double click on it)
2. Java Technologie 9 2.1 Java Virtual Machine Java applications cannot be executed directly They have to be executed by a virtual machine (JVM) The virtual machine is an executable file compiled for the according operating system The java application is contained in a JAR file and can be executed on all operating systems where a virtual machine is available Advantage: Java applications are indendant on the operating system Disatvantage: A JVM has to be installed, Complex calculations in Java code might take longer than in native applications
2.2 Starting a Java application 2. Java Technologie 10 Der command (executable file) is the JVM in this case Its first parameter is always -jar The Java application file (JAR file) is the second parameter Additional parameters that are specified are passed to the application by the JVM Command (JVM) Parameter for the Java application Java application
Titel der Präsentation 11 2.3 Example RandSeq RandSeq is a program to generate equally distributed random DNA and RAN sequences It is written in Java and therefore has to be started via java jar RandSeq expects the following command line parameters: java jar RandSeq.jar <outputfile> <nucleotidecount> <sequencetype> <cytosinerate> <guaninerate> <adeninerate> <sequencetype> can either be dna or -rna The remaining rate for thymine or uracil is calculated from the others