tag:blogger.com,1999:blog-196285267562695572024-03-12T21:09:39.801-07:00Tricks and Tweaks of Open-Source WorldAnonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-19628526756269557.post-56019585677075194032014-01-13T14:51:00.002-08:002014-01-13T14:51:39.681-08:00Create neat excel files in Python using XlsxWriter<div dir="ltr" style="text-align: left;" trbidi="on">
Working with Excel files is not always a great pleasure for me, but regardless of my feelings its a great tool for a lots of situations where dealing with data is easier and faster with Excel. As a programmer I tend to find alternatives to not deal with data directly and build some type of software layer around it to deal with data in Excel files. If you feel like being in the same boat and love <a href="http://python.org/" target="_blank">python</a> then you must use <a href="http://xlsxwriter.readthedocs.org/index.html" target="_blank">XlsxWriter</a>.<br />
<div class="separator" style="clear: both; text-align: center;">
<img src="http://xlsxwriter.readthedocs.org/_images/demo.png" style="border-image: None; webkit-border-image: None;" /></div>
<br />
XlsxWriter - as name suggests is a python package to create/update Excel files. XlsxWriter supports latest 'xlsx' file format and that is a must have feature as most of the excel files are now in this new format. The list of supported features is huge, but the ones that are important to me is below:<br />
<br />
<ul style="text-align: left;">
<li>Compatibility with XLSX file format</li>
<li>Formulas</li>
<li>Formatting support</li>
<li>Data Validation</li>
<li>Defined names</li>
<li>Charts</li>
<li>Outlining and Grouping</li>
</ul>
<div>
<br /></div>
As with most of the open-source tools/packages you won't find a lot of documentation and you'll have to dig through the auto-generated APIs or source code to find out all the available functions and what different arguments means, its not the case for XlsxWriter. It has a great set of 'Intro' documents (Getting Started, Tutorial-1, Tutorial-2, Tutorial-3), that helps you to quickly get started with this package. And once you are hooked to XlsxWriter, you an go through the rest of documentation to find out how to use a specific feature you are interested in. And this package has 40+ examples of showing how to use various features available in this package to generate great Excel files.</div>
Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-36561002960133605282013-05-21T21:06:00.000-07:002013-05-29T09:55:38.266-07:00Advance Argument Parsing in Python: Reading Args from a File<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://python.org/" target="_blank">Python</a> is a great environment to write small scripts to make life little easier. In no time these scripts can become full fledged tool that is used by lot of people and now you have to keep things organized in your script/tool. One of the most important interface/design of a tool is how it handles command line arguments. Python's standard library provides a feature rich <a data-mce-href="http://docs.python.org/dev/library/argparse.html" href="http://docs.python.org/dev/library/argparse.html" target="_blank" title="argparse">argparse</a> module to provide a standardized way for your tool to manage command line arguments. Some of the key features of argparse module are:<br />
<ul>
<li>Parse positional (required) arguments and optional arguments</li>
<li>Generate a nicely formatted -h (help) or usage output and customize it</li>
<li>Parse not only from sys.argv but also from parse from a list or string in your script</li>
<li>Read arguments from one or multiple files</li>
<li>Custom argument types, for example reading csv style arguments or dictionary style arguments</li>
</ul>
<br />
<div>
There are many more features not mentioned here, but you can always take a look at the <a data-mce-href="http://docs.python.org/dev/library/argparse.html" href="http://docs.python.org/dev/library/argparse.html" target="_blank" title="argparse">argparse</a> documentation to find more about it. In this blog post I am going to cover a feature that is really useful - Reading arguments from file. In my experience as the script/tool keeps growing, we just keep adding more and more arguments and the final command line becomes bloated that spans more than few lines of your terminal.<br />
<br /></div>
<h2 style="text-align: left;">
<span style="font-size: large;">
Enabling Argparse to read from file</span></h2>
<div>
<a data-mce-href="http://docs.python.org/dev/library/argparse.html" href="http://docs.python.org/dev/library/argparse.html" target="_blank" title="argparse">argparse</a> module provides built-in support to read arguments from file. To enable this feature, when <a href="http://docs.python.org/dev/library/argparse.html#argumentparser-objects" target="_blank">ArgumentParser</a> object is created, pass <a data-mce-href="http://docs.python.org/dev/library/argparse.html#fromfile-prefix-chars" href="http://docs.python.org/dev/library/argparse.html#fromfile-prefix-chars" title="fromfile_prefix_char">fromfile_prefix_char</a> argument with a valid character as shown in an example below:</div>
<pre class="brush: python" >parser = argparse.ArgumentParser(fromfile_prefix_char='@')</pre>
<div>
This enables parser object to treat any argument starting with '@' character as file and read arguments from that file. For example, a <i>defaut.args</i> file has following content:</div>
<pre class="brush: bash" style="margin: 8px;">--verbose 1
--debug 0
--enable-all
--out output.txt</pre>
<div data-mce-style="padding: 0; margin: 0;" style="padding: 0px;">
This <i>default.args</i> file can be passed to your tool with '@' argument and <a href="http://docs.python.org/dev/library/argparse.html#argumentparser-objects" target="_blank">ArgumentParser</a> object will be able to read all the arguments of the file as they were passed on the command line:</div>
<pre class="brush: bash" style="margin: 8px;">$ ./my_tool.py @default.args</pre>
<div>
Running above command on your command line sets <i>parser.verbose</i> to 1 and <i>parser.debug</i> to 0. Internally <i>ArgumentParser</i> object reads the file, parse all the arguments and place them into a common buffer that holds all arguments, those that are passed on the command line and also that are passed in <i>default.args</i>. One shortcoming of this feature is each line must have only one argument (you can easily overcome this limitation by extending ArgumentParser class, just keep reading..). This enables us to override argument values passed in the file from command line. For example,</div>
<pre class="brush: bash" style="margin: 8px;">$ ./my_tool.py @default.args --verbose 2</pre>
<div>
Above command will set parser.verbose value to 2 instead of 1 that was specified in default.args. This enables users to play with the arguments without changing the default argument files.<br />
<br /></div>
<h2 style="text-align: left;">
<span style="font-size: large;">
Reading Multiple Files</span></h2>
<div>
Because all the arguments are treated equal (either from command line or from file), you can pass multiple file arguments or create a hierarchy by adding file argument within a file. To show an example lets create a <i>debug.args</i> file with following content:</div>
<pre class="brush: bash" style="margin: 8px;">--debug 1
--loglevel 3</pre>
<div>
Now you can pass two files on command line like below:</div>
<pre class="brush: bash" style="margin: 8px;">$ ./my_tool.py @default.args @debug.args</pre>
<div>
This will read arguments from both <i>default.args</i> and <i>debug.args</i>, and it will override <i>parser.debug</i> value to be 1. Another option is to include <i>@default.args</i> in the specific.args at the top as shown below:</div>
<pre class="brush: bash" style="margin: 8px;">@default.args
--debug 1
--loglevel 3</pre>
<div>
And now you only have to pass only one file in the command line like this:</div>
<pre class="brush: bash" style="margin: 8px;">$ ./my_tool.py @debug.args</pre>
<br />
<div>
<h2 style="text-align: left;">
<span style="font-size: large;">
Supporting Comments in a File</span></h2>
</div>
<div>
Now that you have created multiple files and you'll find yourself adding/removing arguments from the file while you play with your tool. It would be nice if argparse can natively support comments but it does the second best thing, allows users to easily extend <a href="http://docs.python.org/dev/library/argparse.html#argumentparser-objects" target="_blank">ArgumentParser</a> class to support comments and many more features.<br />
<br />
The <i>ArgumentParser</i> class implements <a href="http://docs.python.org/dev/library/argparse.html#argparse.ArgumentParser.convert_arg_line_to_args" target="_blank">convert_arg_line_to_args(..)</a> function that contains default implementation of ArgumentParser's file reading feature. The default implementation is very simple, split the line by space and pass each element as argument. In order to support comments in args file, we can create our own parser class that extends <i>ArgumentParser</i> and overrides <i>convert_arg_line_to_args</i> function.<br />
<pre class="brush: python" style="margin: 8px;">class CustomArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwrags):
super(CustomArgumentParser, self).__init__(*args, **kwargs)
def convert_arg_line_to_args(self, line):
for arg in line.split():
if not arg.strip():
continue
if arg[0] == '#':
break
yield arg
</pre>
In above code, <i>CustomArgumentParser</i> class overrides <i>convert_arg_line_to_args</i> function. This function is called for each line in a file. This example treat any string after '#' as comment, just like Python language. To detect comments, convert_arg_line_to_args check for '#' in first character of each element. If '#' is found, rest of the elements from the line are ignored, hence treating it as comment.<br />
<br />
Now create your parser object from <i>CustomArgumentParser</i> and your tool will have one more feature - comments in args file. The comment support is just one example, you can also extend it to support multi-line comments, handling string based arguments etc.<br />
<br />
Python's standard library modules have lots of little gems like this that allows users to extend basic functionality to create robust and powerful tools.<br />
<br /></div>
</div>Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-30606696492220567072011-12-20T08:56:00.000-08:002011-12-20T09:02:03.407-08:00Git patches for subtree<a href="http://git-scm.com/">Git</a> is arguably the most useful and popular tool for source control. I have been using git for more than 3 years now and one feature I like the most is <a href="http://progit.org/book/ch6-7.html">'subtree'</a>. Its a very useful feature when you work on large project which includes multiple projects from different people and you can merge the changes from those remote the projects from one repository.
<br/>
<br/>I have used subtree for pulling changes from <a href="http://wiki.qemu.org/Main_Page">QEMU</a> releases into <a href="http://marss86.org">MARSS</a> . Sometimes when we want to make change to QEMU and send patches upstream, then using 'git format-patch' doesn't work by default because the patch is created with 'marss' has top directory. As shown in the 'git diff' output below:
<pre class="brush:diff , highlight: [3,4]">
diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h
index 7f2103f..7047115 100644
--- a/qemu/target-i386/cpu.h
+++ b/qemu/target-i386/cpu.h
@@ -636,6 +636,7 @@ typedef struct CPUX86State {
#ifdef MARSS_QEMU
target_ulong cr[8]; /* NOTE: cr1 is unused */
uint8_t handle_interrupt; /* Simulater managed int enable flag */
+ uint64_t simpoint_decr;
#else
target_ulong cr[5]; /* NOTE: cr1 is unused */
#endif
</pre>
As highlighted lines 3 and 4 the diff starts with 'qemu' folder. If we want to submit this patch to qemu mainline then it wont work as it should not start with 'qemu'. To solve this issue git diff provides a command line flag <b>--relative=[path]</b>. Now with this flag we can tell the git to generate 'diff' with relative folder. For example,
<pre class="brush:bash">
$ git diff --relative=qemu/
</pre>
will show the diff as below:
<pre class="brush:diff , highlight: [3,4]">
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 7f2103f..7047115 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -636,6 +636,7 @@ typedef struct CPUX86State {
#ifdef MARSS_QEMU
target_ulong cr[8]; /* NOTE: cr1 is unused */
uint8_t handle_interrupt; /* Simulater managed int enable flag */
+ uint64_t simpoint_decr;
#else
target_ulong cr[5]; /* NOTE: cr1 is unused */
#endif
</pre>
So use '--relative' to generate patches to submit upstream. <b>Bonus Tip:</b> You can also use '--relative' with 'git format-patch'.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-36027281687775564962011-09-08T09:06:00.000-07:002011-09-08T09:06:30.704-07:00Awesome 'awk' : variables and conditionsI was working on generating some graphs for my research work and one of the data I needed to collect was from 'tcpdump' output. I had collected all the TCP requests between two simulated VMs using 'tcpdump' where one VM was running LAMP server and other was generating requests to the server. The output of the dump was like below.
<br/>
<pre class="brush:cpp">
18:04:02.898609 IP foxhound.cs.binghamton.edu.40080 > foxhound.cs.binghamton.edu.50847:
18:04:02.898636 IP foxhound.cs.binghamton.edu.50847 > foxhound.cs.binghamton.edu.40080:
18:04:03.121414 IP foxhound.cs.binghamton.edu.40080 > foxhound.cs.binghamton.edu.50847:
18:04:03.121439 IP foxhound.cs.binghamton.edu.50847 > foxhound.cs.binghamton.edu.40080:
</pre>
From that I needed to collect traffic (number of TCP packets per minute) between server and client. Each line was using same format that has time stamp at the start. The challange was to count the number of TCP packet received/sent by the server in a minute. Ofcourse it can be done in python by reading the file, and iterate over each line, split the line data to get the current time and increment the counter for that minute. But I thought that python is an overkill for this simple task. So I decided to use awesome 'awk'.
<br/>
<pre class="brush:bash">
#!/bin/bash
awk '
BEGIN {print "Time, Requests"; hr=0; min=-1; count=0} \
{ split($1,a,":"); \
if (a[2] != min) {\
if(min >=0) {print hr ":" min ", " count;} \
min=a[2]; count=0; hr=a[1] \
} \
count++; \
} \
' $1
</pre>
<br />
Within couple of minutes I came up with above bash script that uses variables within awk to store data over multiple lines and print the output at every minute interval using condition statements. The code shows how easy it is to declare and initialize variables in 'BEGIN' statement. Also by using conditional if statement you can easily manipulate the output of your script. Next time when you run into similar task that requires some basic calculation from text files, let the 'awk' be your swiss knife.
<br/><br/>
<b>Bonus</b>: If you are using 'awk' in a bash script and want to pass a variable to 'awk' then use -v command line option to declare and initialize a variable and use it within your 'awk' script.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-86682067337297861992011-02-09T14:04:00.000-08:002011-02-09T14:04:33.799-08:00chmod to copy user permission to groupIssue I had was simple,<br />
- wanted to give read/write/execute permission to group<br />
- but did not want to end up with 'executable' .cpp and .h files<br />
<br />
If I give 'chmod g+rwx -R dir' then all users belong to my group will be able to access these files but it looked ugly to me. What I wanted was to copy user permissions to group so all users of my group can have same permission as me.<br />
<br />
Solution was so simple (now I think that why I didn't check man pages earlier..)<br />
<br />
<pre class="brush: bash; gutter: false;">chmod g+u -R dir</pre><br />
Thats it and its done.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-6144595601547395642011-01-12T15:55:00.000-08:002011-01-12T15:55:47.833-08:00Setting up github ssh access behind proxy serversAt work to access/update public repo of <a href="http://marss86.org">Marss</a> I finally setup a rather complicated proxy setting for Git which finally worked :).<br />
<br />
I followed the steps from <a href="http://threebytesfull.com/2008/04/git-with-and-without-proxy/"> this tutorial</a> and it worked without a glitch. The only change I did is instead of using 'connect.c' file provided I used standard 'nc' for basic proxy support. So my 'socks-gw' file looks like following:<br />
<br />
<pre class="brush: bash; gutter: false;">#!/bin/sh
# File ~/bin/socks-gw
# Connect a SOCKS 5 proxy using 'nc'
nc -X 5 -x proxy.server:1080 $@
</pre>Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-90537622841320784742011-01-03T16:06:00.000-08:002011-01-03T16:17:40.143-08:00Good Introductory Book on Issues of Parallel ProgrammingFound out a link of this book from <a href="http://reddit.com/r/programming">Reddit Programming</a>, called a <a href="http://kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.2011.01.02a.pdf">'Is Parallel Programming Hard, And, If So, What Can You Do About It?'</a>.<br /><br />I skimmed through this book and trust me if you are into system programming you'll get hooked. I liked the way Paul (author of this book) has explained key obstacles of hardware in parallel programming. Its not too detailed but he has explained the basic issues in a very simple language.<br /><br />Here is a <a href="http://paulmck.livejournal.com/23027.html">link to author's official announcement</a> of this book.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-8132588731163313612010-12-23T10:14:00.000-08:002010-12-23T10:28:59.963-08:00Resizing/Moving Extended Partition in GPartEdYesterday I was trying to setup my old laptop as NAS server and I was trying to setup my old laptop hard-drive (which I was using as portable USB drive) for NAS storage. That old drive still contained multiple partitions including one for Windows installation. I decided to delete windows partition and use it as root partition to install Ubuntu and use rest of the drive as /home for storage. So I created a bootable USB disk of <a href="http://gparted.sourceforge.net/index.php">GPartEd</a> and boot my laptop from USB.<br /><br />The issue came up when I was trying to move and resize my extended partition. One of the partition had lot of data that I didn't want to loose so formatting the whole disk was not an option for me. For some reason gparted was failing on moving my extended partition and it said that can not move/resize it. I googled for some help in various linux forums and found <a href="http://ubuntuforums.org/showthread.php?t=1260788">this post</a> in Ubuntu forums about someone had similar issue. He/She tried 'swapoff' option on 'swap' partition and it worked for him. But for me, 'swap' was already in 'swapoff' mode. So no luck there.<br /><br />Then I tried something new based on that, I deleted the 'swap' partition that was in 'extended' partition, applied all the changes. Then I tried to resize and move my extended partition and it worked!!<br /><br />Once again, thanks <a href="http://ubuntuforums.org/">Ubuntu Forums</a>.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-64926761848352121962010-12-20T12:45:00.000-08:002010-12-23T12:44:03.057-08:00Using launchpad PPA behind proxyI was trying to setup my <a href="http://ubuntu.com">Ubuntu</a> VM in work machine and I was trying to install <a href="https://launchpad.net/~chromium-daily/+archive/ppa">Chromium-daily build ppa</a> from <a href="http://launchpad.net">launchpad</a>. I have global proxy setup in my account but when I tried to setup the PPA it was not working. So standard method<br /><br /><pre class="brush: bash; gutter: false;">sudo apt-add-repository ppa:your-ppa</pre><br /><br />was not working. The alternative was to manually set repository and authenticate the repo via 'apt-key' as shown below:<br /><br /><span style="font-weight: bold;">Step 1:</span> Add the repository via 'apt-add-repository' without authenticating its GPG key.<br /><br /><pre class="brush: bash; gutter: false;">sudo apt-add-repository 'deb http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu jaunty main'</pre><br /><br />Here replace the repository info.<br /><br /><span style="font-weight: bold;">Step 2:</span> Authenticate the repository using 'apt-key'. First get the PPA key info from its web page. For Chromium-daily build the key is 4E5E17B5. Use following command to authenticate using http-proxy settings of your machine.<br /><br /><pre class="brush: bash; gutter: false;">sudo apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy="http://your.proxy.server" --recv-keys 4E5E17B5</pre><br /><br />If things goes well then you will see a message from gpg saying 'Total number processed: 1' and you should be able to install your software from either Synaptic or Ubuntu-Software-Center.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com3tag:blogger.com,1999:blog-19628526756269557.post-51441037023103104402007-10-30T20:56:00.000-07:002010-12-23T12:49:37.924-08:00Check your hard-drive's remaining lifeIts always a horrible scenario when your hard-drive crashes - and adds more ghosts to it when you have important data into it.<br /><br />It would always be nice to have some tool that can be used to find out the approximate life period remaining of your hard-drive. Well in newer SATA hard-drives they are using a Load/Unload mechanism for separating the disk and head. (detail explaination: http://www.linux-hero.com/rant/explanation-ubuntu-hard-drive-wear-and-tear).<br /><br />In linux machines you can install 'smartmontools' to find out some interesting information about your hard-drive. This tool uses S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) technology available in new hard-drives. This gives a specific count of Load/Unload done on your hard-disk. Normal hard-disk has 600,000 of Load/Unload cycles. Following is the method to find out the remaining life time of your hard-disk.<br /><br />If you are a ubunbtu user like me simply give the following command:<br /><br /><pre class="brush: bash; gutter: false;">sudo apt-get install smartmontools</pre><br /><br />It will install 'smartmontools' to your system. After than give the following command<br /><br /><pre class="brush: bash; gutter: false;">sudo smartctl -d ata -a /dev/sda | grep '193'</pre><br /><br />It will show output something like this:<br /><br /><pre class="brush: bash; gutter: false;">193 Load_Cycle_Count 0x0012 097 097 000 Old_age Always - 30385</pre><br /><br />Here in the last the number is 30,385 which is load/unload cycle count of my hard-drive. Well my drive is only 1.5 months old and it has already used 30,385 cycles.Anonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0tag:blogger.com,1999:blog-19628526756269557.post-70650385461468024492007-07-31T06:32:00.000-07:002007-07-31T07:43:33.186-07:00Magic Audio & Video tricks using SSH and XThink of this: Your friend is working on your Linux desktop machine, and you are working on another Linux machine either at home or office. Your friend is editing some files and BOOM - speakers start making horrifying sounds, some horror video starts playing as full-screen mode... And if you have access to your home's electricity connection from that computer then your friend is going to have the worst experience with ghost!!!<br /><br />I will let you think of more horrifying tricks later on after you know how to setup environment like this. All you need is SSH daemon running on destination machine and access to that machine using internet. Of course you must have access to user account that has all the permissions to running X server, a root access will grow two horns on your head !!!<br /><br />If you are new to SSH, you should see <a href="http://www.suso.org/docs/shell/ssh.sdf">this</a> tutorial on SSH.<br />Setting up the SSH daemon in server machine is simple, install 'sshd' package and as root give following command:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >root@servername# sshd</span><br /><br />It will start a ssh daemon and you are all set to login from remote machine.<br /><br />Login using SSH with -Y option:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@localname$ ssh -Y username@servername</span><br /><br />Using -Y you can securely forward all X11 connections to your local machine. So now fire-up your loved MP3 music player (i prefer <a href="http://amarok.kde.org/">amarok</a>, great player with great interface) and your familiar window will greet you. So when you start playing music, it will use server machine's speakers, not local machine's !!! You can download some horrifying sounds and set up a script to play them one by one to be prepared for horror attack...<br /><br />Now as you can see that we can open almost any GUI window in local machine, lets start playing some video using <a href="http://www.videolan.org/vlc/">vlc</a> or <a href="http://www.mplayerhq.hu/design7/news.html">mplayer</a>. But whats this, the video is played in local machine... Well to play the video in server's monitor screen, which is screen no 0 (or in pure X term display :0.0 ). To make sure that your video plays on server's monitor not in local, change your DISPLAY environment variable from localhost:10.0 (somthing like that) to :0.0 .<br /><br />Check your DISPLAY variable value in your ssh session:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ echo $DISPLAY</span><br />If its not set to :0 simply change it using following commands:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ export $DISPLAY=:0.0</span><br />or if you are using 'csh':<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ setenv $DISPLAY :0</span><br /><br />To make sure that the X display number is :0.0 , give the following command in your ssh session:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ ps -ax | grep 'X' </span><br />It will show something like this:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ </span><span style="font-family:courier new;"><span style="font-weight: bold; color: rgb(51, 255, 51);">3744 tty7 Ss+ 2:01 /usr/bin/X :0 -audit 0 -br -auth /var/lib/gdm/:0.Xauth vt7</span><br /></span><br />Here, the value after '<span style="font-family:courier new;">/usr/bin/X</span>' is '<span style="font-family:courier new;">:0</span>' so your display number is 0. If there are more than one display running than you may have to do trial and error to find the display number.<br /><br />Now you are set to play videos in server machine's monitor. Use vlc with following options:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ vlc -f videoname.avi</span><br />or if you like mplayer:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ mplayer -fs videoname.avi</span><br /><br />Now you have learn the dark side tricks of SSH go and practice it to be master of it. And when you successfully execute this mission don't forget to tell me your friend's reaction!!!<br /><br />NOTE: If you try to use <a href="http://www.mozilla.com/en-US/firefox/">firefox</a> over SSH, when we give normal 'firefox' command it runs locally not remotely, so music will be played in local machine. To fix this problem start the firefox with following options:<br /><span style="font-weight: bold; color: rgb(51, 255, 51);font-family:courier new;" >user@servername$ firefox -no-remote</span><br /><br />This will start the firefox in remote machine so any music played in it will play in remote machine's speakers.... enjoy.<br /><br />- Avadh PatelAnonymoushttp://www.blogger.com/profile/17136443261145576521noreply@blogger.com0