cli

how to make a PHP file run-able only through CLI mode?

It's available to browser, but I don't want it to execute when browsed by user, say,when browsed should exit, is there a way to detect whether it's currently Cmmand Line Mode? ...

Interpret and execute arbitrary Javascript in Linux CLI

I've been looking for ways to do this for a while but haven't quite been able to find the right way to do it. The task: Execute Javascript from a Linux command line. For example, have the binary or whatever is going to interpret Javascript load up some .js files, then print a value of some variable. More concrete example: I would like...

What are the basic arguments every good CLI application must have?

myapp /? myapp -help myapp -ver etc.... ...

Ping from Dynamic Language without using 'ping'

I'm on a Linux system where I am not allowed to use the 'ping' application (ping: icmp open socket: Operation not permitted). However, the script that I am writing (PHP, but I can use an exec() call to any script/program if needed) needs to determine if a host is 'alive'. How can I go about this without using 'ping'? ...

How to check with PHP if the script is being run from the console or browser request?

I tried things like $_ENV['CLIENTNAME'] == 'Console' but that seems to work on only certain OS's (worked in windows, not linux). I tried !empty($_ENV['SHELL']) but that doesn't work always either... Is there a way to check this that will work in all OS's/environments? Thanks! ...

PHP.exe (CLI) can't connect to MySQL while Firefox can!

Hi, I have installed XAMPP on a Windows XP Machine. PHP scripts are working fine through the browser. Initially, PHP.exe (CLI) was failing with error - can't load php_pgsql.dll I disabled extension=php_pgsql.dll in the php.ini file and PHP.exe stopped to fail. However, even now I am not able to run a PHP script from the CLI even thou...

What is the best way to display percent complete in a .Net CLI application?

I'm working on a CLI application that deals with uploading of files, and would like to have a combination of appended and overwritten output. Ideally it would look something like this: c:\>upload file1.dat 100% file2.dat 100% file3.dat 59%, 36.4k/s I'd like just the last row to periodically update the percent compl...

Javascript function results in HTML page reload: why?

Hi all, Newbie question... The objective: I intend to have an HTML text input field as a kind of command line input. An unordered HTML list shows the 5 most recent commands. Clicking on one of the last commands in this list should populate the command line input text field with the respective command (in order to re-execute or modify...

Strange performance increase in projects compiled in VS 2008 comparing with VS2005

I have a 3rd party library and a simple benchmark test that I write by myself to test this library for performance. 3rd party library is C++/CLI .NET library and most code there is unmanaged. This library is assembled for .NET Framework 2.0. My benchmark test is managed C# code that adds little overhead to the library, only simple calls ...

Why does my C# array lose type sign information when cast to object?

Investigating a bug, I discovered it was due to this weirdness in c#: sbyte[] foo = new sbyte[10]; object bar = foo; Console.WriteLine("{0} {1} {2} {3}", foo is sbyte[], foo is byte[], bar is sbyte[], bar is byte[]); The output is "True False True True", while I would have expected "bar is byte[]" to return False. Apparently ...

Java library for parsing command-line parameters?

I write a little command-line-application in Java. This application should work with a mix of parameters and commands, a little bit similar to the 'svn'-command. Examples: app url command1 app url command2 --parameter2 -x app url command1 --param-with-argument argument app --parameter url command1 app --no-url command2 app --help Exi...

Java: How could I "intercept" Ctrl+C in a CLI application?

Hello! How could I "intercept" Ctrl+C (which normally would kill the process) in a CLI (command line interface) Java application? Does a multi-platform solution exist (Linux, Solaris, Windows)? I'm using Console's readLine(), but if necessary, I could use some other method to read characters from standard input. ...

PHP APC in CLI mode

Hi, Does APC module in PHP when running in CLI mode support code optimization? For example, when I run a file with php -f <file> will the file be optimized with APC before executing or not? Presuming APC is set to load in config file. Also, will the scripts included with require_once be also optimized? I know optimization works fine wh...

switching between console mode and graphical mode

Hello. I just wanted to know if there is some way to switch between console mode and graphical mode. I am using java on swing. I'd like to know if I can type something in the shell to go to a console mode, then type something to go back to the desktop. Or if I can press some key at boot time, or something. The idea is to make my server...

How to run multiple PHP scripts from CLI

I have three different crawler scripts that I want to run in parallel and I'm wondering what command do I use to execute all three at the same time. I'm on a nix platform ...

Python cmd module command aliases

I am making a command line interface in Python 3.1.1 using the cmd module. Is there a way to create a command with more than one name e.g. "quit" and "exit"? Or would it just be a case of making a number of commands that all reference the same function? ...

How to collect HDD size and available or used space in linux cli?

I'm trying to find some sort of command or regex to get the size and available or used space of a hard drive in linux. At the moment I'm using this; df -h and getting something like this; Filesystem Size Used Avail Use% Mounted on /dev/sda1 10G 3.1G 6.4G 33% / /dev/sda2 147G 5.8G 134G 5% /...

How can I make Twitter from the terminal display Hebrew characters correctly?

I've been using the Perl solution for Twitter via Terminal: IRSSI + TWIRSSI for the past couple of days. Amazing. The feeling so nostalgic yet so futuristic; beautiful. However, one problem still stands: Hebrew letters result as gibberish: Any idea how or where to I can modify the script to work in a readable Hebrew? Thanks, and G*d ...

Generating thumbnail for various files by wrapping Linux CLI program

There are various programs available for generating thumbnails for different file formats. For PDF there is ImageMagick, FFmpegthumbnailer for movies and so on. Does anyone know about a Linux program that's able to create thumbnails for different file formats? I don't care if that's just a wrapper on top of other programs as long as it g...

how to specify the terminal width in mysql CLI

I'm using the mysql CLI, however the result displays always wraps around on my terminal screen. is there any way to specify to mysql the size of my terminal screen? ...