Thursday, August 23, 2012

Log BASH command error and write the output to a file along with the STDOUT

BASH shell error (STDERR) is displayed on the screen by default.  For the following find command, all the output, including error is displayed on screen

find /var/lib/. -name “*.py”

bash$ find /var/lib/. -name "*.py*"
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied


If the following command is used, it will only write out the ‘find’ result to the log file, not any error.

find /var/lib/. -name “*.py” > find_py.log

How can you log the error along with the output to a file so that you can read it later or from a remote session?


Follow the commands and output below


find /var/lib/. -name “*.py” > find_py.log 


[Only STDOUT written to a log file; (STDERR output to screen only) ]

bash$ find /var/lib/. -name "*.py*" > find_py.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied

bash$ cat find_py.log
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc



find /var/lib/. -name “*.py” 2> find_py.log


[Only STDERR written to a log file; (No STDERR output to screen; Only STDOUT output on screen)]

bash$ find /var/lib/. -name "*.py*" 2> find_py.log
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc

bash$ cat find_py.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied

find /var/lib/. -name “*.py” 2> find_py.log 1>&2 


STDOUT and STDERR written to a log file; (Nothing output to screen)

bash$ find /var/lib/. -name "*.py*" 2> find_py.log 1>&2

bash$ cat find_py.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied



find /var/lib/. -name “*.py” 2>&1 | tee find_py_tee.log


STDOUT and STDERR written to a log file; (Also displayed on screen live while writing the log)

bash$ find /var/lib/. -name "*.py*" 2>&1 | tee find_py_tee.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied

bash$ cat find_py_tee.log
find: /var/lib/./zfs: Permission denied
find: /var/lib/./dav: Permission denied
find: /var/lib/./mlocate: Permission denied
find: /var/lib/./php/session: Permission denied
find: /var/lib/./ldap: Permission denied
find: /var/lib/./aide: Permission denied
find: /var/lib/./dovecot: Permission denied
find: /var/lib/./nvidia: Permission denied
find: /var/lib/./nfs/statd: Permission denied
find: /var/lib/./pgsql: Permission denied
find: /var/lib/./sss/pipes/private: Permission denied
find: /var/lib/./sss/db: Permission denied
find: /var/lib/./iptraf: Permission denied
/var/lib/./zope/bin/zopeservice.py
/var/lib/./zope/bin/zopeservice.pyo
/var/lib/./zope/bin/zopeservice.pyc
find: /var/lib/./imap: Permission denied
find: /var/lib/./mailman/archives/private: Permission denied
find: /var/lib/./dhcpv6: Permission denied



The 2>&1 redirect STDERR to STDOUT.
This will record any errors to the logfile along with STDOUT.

Saturday, May 12, 2012

Dell Streak 5: USSD code problem fix for Gingerbread 2.3.3

hunderteins of XDA form has done an excellent job to fix the USSD code problem in Dell Streak 5 Gingerbread Android 2.3.3. TheManii put it easy for us to update the fix comfortably using StreakMod.  It's working perfect for me and you can try it if you want. If you want to fix, here's the detailed instruction on how you can fix it.


This tutorial assume you have Gingerbread installed in your DS. If you have already flashed streakmod, skip the first part. If you have rooted following my previous post, you may already have flashed StreakMod.


Requirements and downloads




  • Unzip to a folder; say C:\Fastboot+ADB



Process overview:
A) Enter fastboot mode and flash the streakmod custom recovery
B) Reboot to the streakmod recovery and select option 2 and then ‘update from update.zip’ to select update-USSDfix-2.zip





A) Flash the streakmod custom recovery
  • Connect  your DS to PC (You already installed drivers to it) and copy update-USSDfix-2.zip to the DS SD card.
  • Stop USB connection and power down DS (DS is still physically connected to the PC through the cable)
  • Press and hold down the camera button and then press the power button. Release the button when you see a white screen
  • Select Fast boot mode on the top right on your mobile (DS display will show FASTBOOT_MODE)
  • Now it’s time to do some DOS commands from your PC to communicate with DS through the connected USB cable.
  • On your PC, navigate to the path where you unzipped the fastboot tools.(C:\Fastboot+ADB). You have already copied the streakmod recovery (C:\Fastboot+ADB\Win32\recovery.img) to this folder. (see requirements)
  • Press Shift key and from right click menu open a DOS command window on that folder
  • Type  'fastboot -i 0x413c flash recovery recovery.img' without the quotes and hit enter. You can see that your DS screen shows the response.(By the way, you can copy paste the commands to the DOS prompt. Right click on DOS command and paste.)
  • Type 'fastboot -i 0x413c reboot' without the quotes and hit enter.  
B) Reboot to the streakmod recovery, select option 2 (update) and select ‘update from update.zip’ to select update-USSDfix-2.zip file.

  • On reboot, immediately go in recovery mode (hold both volume buttons while powering on). Don’t let it go to full system boot yet.
  • Select option 2: Update from update.pkg on sdcard. Now this would go to be the custom streakmod recovery. (See version number at lower bottom in yellow font. If not, you are not on StreakMod and you can't proceed) 
  • Select
  • update-USSDfix-2.zip
  • and proceed instructions to patch
  • Now the patching process will start and finish. On rebooting, your DS will regain the USSD power! Try your USSD code and see if it works. 
  • [Optional] Post your experience here if you feel like. :)
Thanks again to XDA geeks hunderteins, TheManii, DJ_Steve and the rest 
Reference

Tuesday, February 14, 2012

XPS15z: USB 3.0 incompatibility and problem with external hard disks


Dell XPS 15z laptop's USB 3.0 ports does not work with at least one USB 3.0 external hard disks out there; Toshiba Canvio 1 TB USB 3.0 portable external HDD.

Check the Dell forum for the details of the problem.
XPS 15z laptop USB 3.0 problem

The hard disk works fine with the USB 2.0/eSATA combo port at USB 2.0 speed. (~30MB/s). The hard disk is not recognized at the USB 3.0 port. When I plugged it, the hard disk blinked with blue light continuously and nothing happened. The same HDD gives around 90 MB/s data transfer speed in my Desktop's USB 3.0 port indicating that the hard disk works fine.

So far, the mother board has been replaced and that didn't fix the problem. A newer laptop also had the same problem. It appears to me that the USB 3.0 port does not provide sufficient power to such external hard disks. To test this, I purchased a cheap USB split Y power adapter cable and plugged the external hard disk to both of the USB 3.0 ports at the same time; the additional plug is expected to provide the extra power to the hard disk. My suspicion was right; now the hard disk is recognized by Windows. Since the split cable I bought supported only USB 2.0, I get only about 30 MB/s speed. 

Now one option for me is to get a USB 3.0 power adapter split Y cable if I need the super speed with this hard disk, which is about three times of the USB 2.0 speed in real life. Three times speed is useful if you have huge data to transfer; say you'll be done in 20 minutes instead of 1 hr.

Is it a design flaw from Intel in manufacturing such a motherboard? Is it Dell's fault in not disclosing this potential incompatibility to the customers when advertising USB 3.0 as a specification of the laptop? Or is it a problem from Toshiba in making a power hungry external hard drive? Who sets the standards for USB 3.0 power specification and requirements? (if there is such a standard).

I've no idea.
__________________
Update on April 18th 2012

Previously, I reported that the drive works with USB 2.0 Y split cable. It could transfer files in USB 2.0 high-speed (~30 MB/s) from that connection. But to get the USB 3.0 super-speed (~90 MB/s), I purchased a USB 3.0 split Y cable from Amazon.com. As I expected, the drive did work this time with USB 3.0 transfer rate. The problem is solved. But two of my USB ports are gonna be occupied if I want USB 3.0 speed. Well, at least it works. So finally, the problem seems that either the Dell XPS 15z doesn't provide sufficient power to the USB Hard disk or this specific USB hard disk is under powered from a single USB port. 

Hey, Dell, Intel, Toshiba....who is ready to take the responsibility?