Malayamarutham is a mellifluous raaga in carnatic music which will make one soft at heart. In telugu, malaya maarutham is a cool evening breeze which invigorates mind, body & heart.

Feedback, suggestions, criticisms, typos, mistakes, errors etc., (no matter how small you think they are) on the articles of this blog are very welcome. They can be directed to kamaraju at gmail dot com.

Search This Blog

Thursday, June 04, 2009

running external commands

To run external commands while editing a file in vim, use the '!' in the normal mode. For example

:!ls -al

will list the files

:!date

will display the current date.

To read the output of external commands into the current file, do

:r !date

All the commands are run in normal mode. Press ESC key to enter the normal mode in vim.

Further reading:- :help :!

To run external commands in octave, use the system command. Sample octave session looks as

Further reading :- "doc system" shows the relevant help pages in octave.

To run external commands in Fortran 90 programs, use the system command. Sample code looks as below

$cat system.f90program callsystem implicit none !to examine the behaviour of the system command character (len=100)::cmd cmd="echo Wake up Neo" !if u are using ifc compiler use -Vaxlib during compilation call system(cmd//achar(0)) call system(cmd) call system("date") ! The next line also works. ! call system("ls")end program callsystem

$gfortran system.f90

$./a.outWake up NeoWake up NeoThu Jun 4 23:55:07 EDT 2009

To run the external commands in C, use the system command available in stdlib.h. Sample code will be