Tuesday 15 July 2014

Jacl to Jython Conversion


The IBM Jacl to Jython Conversion Assistant (Jacl2Jython) is a program that assists in converting WebSphere administrative (wsadmin) scripts written in Jacl into Jython syntax.

This utility is a product of IBM and used for wsadmin scritps written on jacl and the results of conversion are syntactically equivalent but not 100% ready to execute. Manual correction and validation is required most of the time for complex jacl scripts.

If any line is difficult to convert automatically by this program, these preliminary converted lines of script are flagged #?PROBLEM? which needs manual verification.

This Utility you can download here and for detailed descriptions of this conversion utility. Unzip the pack. 




Set your JAVA_HOME environment variable in server/computer's command line and then change accordingly the [Jacl2Jython bat|sh]



 





SYNTAX :

Jacl2Jython.bat your_jacl_script.jacl




EXECUTION: 


Place the .jacl file in the same folder and execute(In my example it is test.jacl)




 
OUTPUT :

 You can see a python file generated for this jacl script in the same folder. Verify throughly the python script for any errors. 

 


Sunday 13 July 2014

What does "> /dev/null 2>&1" means in a shell program ?

What does "> /dev/null 2>&1" means in a shell program ? 


REDIRECTION : 

"A > B" means, It truncates the output of A to B
"A >> B" means, It Appends the output of A to B

The above two redirections methods can be usually used to redirect to a file, but it can be a device as well. 

SYNTAX : command_A > /dev/null 2>&1

DESCRIPTION : The greater than symbol(>) in commands like these, writes the output somewhere. In this case, command_A is being redirected into /dev/null, and "2" is being redirected into &1.

STANDARD IN, OUT and ERR :

STANDARD INPUTS(STDIN/"0"/fd0) :  (i) usually gets input from (KEYBOARD), if it is an interactive program, (ii) or output of another program can be redirected as input
STANDARD OUTPUTS(STDOUT/"1"/fd1) : Input programs usually prints to standard output(SCREEN) if it doesn't get any compilation error
STANDAR ERROR(STDERR/"2"/fd2) : Used to write diagnostic or error messages(SCREEN)

STDIN = 0 or fd0
STDOUT = 1 or fd1
STDERR = 2 or fd2

where fd=file descriptor

P.S : By default, if you don’t name or number one explicitly, It will be considered as 1


/dev/null : The null device in any Operating System is typically used for disposing of unwanted output streams of a process. The /dev/null device is a special file, not a directory, so one cannot move a whole directory into it with the Unix mv command. Data written to this file gets discarded. It is similar to the file call NUL on Windows machines.

You can see the command_A above is redirecting standard output of command into /dev/null, then redirecting standard error(2) into standard output. & in front of the destination is must. The & informs the shell to put the command in the background. '&' indirectly indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.

In a single statement : "All output from this command_A should gets discarded except the error messages"