Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

How to uncompress a WAR file using command

Answer:

To un-compress a Java Web Archives file (*.war), you can use the command

# jar xvf my-app.war

Print to standard output in different scripting languages

Answer:

To print a string of "Hello World" to the standard output in different scripting languages

1. Perl

print "Hello, World!";

2. Python

print('Hello, World!')

3. PHP

echo "Hello, World!";

4. Ruby

puts "Hello, World!"

Enable Perl strict mode to restrict unsafe constructs

Answer:

In Perl, you can enforce using the strict mode to reduce the chance of nasty error, e.g.

$foo = 'bar';
print $foo;

If you run the above problem, it is completely valid.

# perl test.pl
bar

However, if you use the strict pragma

use strict;

$foo = 'bar';
print $foo;

And run the program again..

# perl test.pl
Global symbol "$foo" requires explicit package name at test.pl line 3.
Global symbol "$foo" requires explicit package name at test.pl line 4.
Execution of test.pl aborted due to compilation errors.

Since the $foo is not declared before the first use, so the compilation stopped. In modern Perl developements, it is recommended to alwasys use the strict pragma in order to write a better and maintainable program.

How to install a NodeJS module using npm globally

Answer:

By default, node modules installed using simple node install will be installed under the folder ./node_modules. In order to install the modules globally, try

# sudo npm install express -g

The above command install the express module as global module.

Install the node package manager (npm)

Answer:

npm is a package manager for node.js, to install it under Linux, just a single command:

# curl http://npmjs.org/install.sh | sudo sh