Programming :: Watch Not Interpreting Escape Codes In Bash Script

Jul 19, 2010

I need a script that can print some series of strings in colors based in the information of a file, for simplicity let's say it only does:

Code:
#!/bin/bash
printf "e[1;31;32m%-10se[00m" "OK"

When you execute this in the command line it prints a bold green 'OK'. So far so good.

Now, I need to check the output of the script over time using the command watch. The problem then arises. watch seems to ignore the escape codes and just prints:

Code:
[1;31;32mOK [00m

Is there any way to fix this?

If not, how can I check inside the script if it is being executed from a command? (watch in this case) So I can print without color for those cases.

View 4 Replies


ADVERTISEMENT

Red Hat :: SSH Banner Escape Codes?

Sep 22, 2010

I have modified /etc/issue with the following:

Code:
Today is d @
So when logging in locally you get todays date and time. I want this for SSH users as well

[code]....

View 1 Replies View Related

Programming :: Escape '*' In Case Statement Bash

Jan 23, 2010

Does it possible to escape * in the case statement

Code:

View 2 Replies View Related

Programming :: Double-quotes Do Not Escape Properly (bash=python)?

May 2, 2010

I wrote the Automatik widget (you can find it at :http://kde-look.org/content/show.php...&PHPSESSID=caeTo improve it, I would like to add this one-line script into a text sensor :

top -b -n 1 | head -12 | tail -6 | sed '/top/d' | awk '{ printf "%-12.12s %-4s %-4s %-3s
" , $12,$9,$10,$2}'

[code]...

View 3 Replies View Related

General :: Escape Characters In Watch Command

Oct 20, 2009

Need little advice running this command.
watch -d 'ps aux | awk '{print $4" "$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr | head'

I get this error message from AWK. awk: cmd. line:1:
{print awk: cmd. line:1: ^ unexpected newline or end of string

I have tried all the usual by trying to escape the single and double quotes in the command but same result. The end result should be the a listing of memory hungry processes that are scanned every 2 seconds (watch default value).

View 2 Replies View Related

Software :: Compile .jar Java Byte-codes Into Native Machine Codes?

Aug 28, 2010

I think I put this in the wrong place

View 1 Replies View Related

Programming :: Error Codes In A For Loop

Nov 3, 2010

I've got a 'nested' for loop which has a grep in it, if the grep fails there's no output - however the error code is still $0 and the second for loop is still entered, there's also a grep in the second for loop.I guess ultimately what i need to know is whether there's a way of making grep generate an error code. when no results are found?

View 14 Replies View Related

Programming :: Escape Characters In System?

Nov 11, 2010

My goal is to send escape characters from Linux to make scanner's LED blink. I've started with a simple "beep" command:
echo -e "�7"

and it worked. We are using WaveLink emulator and the escape sequences for the LED are
echo -e "�33%150;200;5L"

Linux returns me this: 150;200;5L
So, it doesn't work. What am I doing wrong for the LED sequences?

View 1 Replies View Related

General :: Bash Watch Command With Colors Preserved?

Mar 29, 2010

From man watch: Non-printing characters are stripped from program output. Use "cat -v" as part of the command pipeline if you want to see them. So how do I use cat -v if I want to see the colored output from:watch ls -al --color

View 3 Replies View Related

Programming :: Build Whole Distribution From Source Codes?

Dec 11, 2008

I have downloaded whole linux source codes of fedora in a dvd. There are several rpm packages and lots of directories in it. I want to load all source codes to version control system (svn or cvs) which is loacated in a server and develop it step by step .During this time I want to build my own distribution. So I need to know how to build all these packages at once. Is there anyone who can explain "how to do" to me

View 1 Replies View Related

Programming :: Hide C++ Codes In An Executable File?

Apr 4, 2011

I wrote a c++ program but for security reasons I need to make sure that no one can read my codes by my ".out" files. I did everything I could. But everyone can see it by "strings Alpha.cpp".I heard that g++ has some options to do so.

View 7 Replies View Related

Programming :: Transfer C Codes From UNIX To System?

Jun 16, 2010

I got some problems and need your help.

In school, my codes are writeen under UNIX system (Solaris10/SUN), now I need to transfer those codes to Linux (Redhat5). But after I directly copy to Linux, it shows many errors and warnings.

Does anyone know which codes I need to modify to specifily suit for UNIX? I am not familiar with those systems and hope to get your kind help.

View 5 Replies View Related

Programming :: Need Exploit Codes For An Echo Program In C?

Mar 13, 2011

I am a student taking part in a comptition. We have a set of questions to complete within today. Can anyone please help me out with it. I have a custom written "echo" program in C, running on port number "1220" which echoes back the first 16 characters of whatever is given as the first command line argument. But somehow, my brother had got unauthorized remote root access. The program is given below. How did he do it? Please give the exploit code and explain how it works.

#include
#include
void echo(char* input) {

[code]....

View 2 Replies View Related

Programming :: Perl - Escape All Backslashes In A String Without Specify Each One ?

Sep 27, 2010

I want to read a input from user and output something like 'inputcd', which has to escape all backslashes if using double-quote. For instance, the following code would work.

Just curious if any other way I could do it without specify all backslashes? Since that takes much efforts when the sequence is long.

Code:

View 2 Replies View Related

General :: Bash Scripting - Sed - Lame - Character To Lame To Escape Spaces

Mar 20, 2010

Ok, so I find myself ripping audio CDs frequently, which I then lame to mp3's to put on my media player. I usually define the --ta and --tl (artist and album) ID3 tags and batch encode each album, but don't bother with the track tags as I'd have to do each one seperately.

So, I'm working on a script to do all this for me, extracting info from 'pwd' etc. to fill in the blanks for --ta, --tl and --tt (track name). All is working well, except that I can't get sed to pass on the "" character to lame to escape spaces.

Here's what I've got so far: (trouble spot is bolded - no need to pay attention to the rest of it)

Code:

All this does is pass a 'space' on to lame, which it takes as an invalid argument.

View 10 Replies View Related

Programming :: Implement Some Part Of Codes To Use The GPU Of Graphic Card?

Sep 25, 2010

I wish to implement some part of my codes to use the GPU of my graphic card but I have no idea whether GNU as already implemented it (as for OpenMP). I mean, there are PGI Fortran compiler which embedded CUDA but I figure it's not free. I also wonder if that works only with ATI graphic cards or if for instance I can use my Intel Corporation Mobile GM965/GL960 Integrated Graphics Controller.

View 4 Replies View Related

Programming :: Regular Expression Double Escape For Files That End With .la ?

Mar 18, 2010

I have been battling with regular expressions and am a little lost. I want to find all my files that end with .la and have been trying this

Code:
slocate -r .la$

which finds them but also files like mozilla. The escaped full stop seems to be ignored however this works :

Code:
slocate -r \.la$

so why is the double escaping needed ?

View 3 Replies View Related

Programming :: C++ Codes To Check Whether User Is Root Or Has Admin Rights

Jan 8, 2011

One of the feature in my application involve changing of hardware setting. This require the user to be root or have administrative right.Before my application enable that feature, I want it to check whether the user is "root" or not, or whether user use "sudo" command to run the application or not, or whether the user has administrative rights or not.What are the codes or library that can do this?

NOTE: Sometimes, advanced linux user may set the user id of root to something else other than 0. So, getuid() may not be helpful in this case.

View 4 Replies View Related

Programming :: Watch For Keyboard Input Without Waiting In C?

Jan 25, 2011

I have a C program that may finish in seconds or weeks depending on the data. For the longer jobs I want to be able to press a key and get an intermediate result printed.

View 14 Replies View Related

Ubuntu Servers :: Interpreting Mdadm RAID1 Status?

Feb 7, 2011

I have a RAID1 array, where mdadm states that one of the disks is "removed." Naturally, I assume one of the drives has failed. The mdadm --detail command tells me that the sda drive has failed. However, further inspection from the mdadm -E /dev/sdb1 command says that sdb1 disk has been removed. I am a bit confused. Can someone clarify which drive is failed? Am I misreading the command outputs?

Code:
sudo fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

[Code]...

View 3 Replies View Related

General :: Interpreting Output Of Memory Tools In RHEL 5.3?

Mar 15, 2010

I have been doing a lot of research on the web to piece together the components I need to understand what is probably a very simple thing. I've read up on buffers/cache vs. physical memory and using free -m and top and understanding that output, and reviewed Red Hat's article on virtual memory. I am hoping to get some assistance in putting it all together to understand what's happening in my situation because so far I have a lot of dangling factoids and no glue. I have also referenced the thread http://www.linuxquestions.org/questi...memory-309767/ but I didn't find my answer there.

My company is running a cluster of physical web servers (they are clones so running the same OS, with same RAM and applications installed). I'll be referring to a single system although the question applies to all because they're all showing similar output. The Multi Router Traffic Grapher is showing a steady swap usage for 3-4 months now. The average usage for today is 81%. There is, as far as I know, no performance hit because of it, but a developer noticed this and wanted to know what was going on, and I'd using this opp to learn. The system is Linux version 2.6.18-128.7.1.el5, running JBOSS, postgres, Apache, and Java. Here is the output from the memory commands I have used to try and understand what's going on.

Code:

top - 21:19:27 up 159 days, 7:43, 1 user, load average: 0.52, 0.61, 0.64
Tasks: 144 total, 1 running, 143 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.2%us, 8.0%sy, 0.0%ni, 91.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

[code]....

So my interpretation of this output tells me that my system has 4GB of RAM installed, 23MB of free "physical" RAM, and 1.35GB of RAM in cache (according to the second line of free -m, which represents free physical memory and useable mapped memory if I understand correctly). I have a 2GB swap partition, 1.5GB of which is currently being used, and according to the MRTG is the average that has been in use since January. So the swap size isn't decreasing. Java (JBOSS) is using the most physical RAM at 1.6GB.

My question is: if I have 1.35GB of RAM cached, why is my system using all of that swap space and not using any of the cached RAM? I thought I understood that Linux is supposed to either re-use unmodified pages in cache or send older pages to disk when more RAM was needed. It seems like my system is always sending pages to disk, which I guess would normally mean I just need more RAM but, to have close to the same swap size consistently seems like there must be more to it.

View 3 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

Feb 4, 2011

I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.

View 3 Replies View Related

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

Jan 24, 2010

simple bash code:

Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do

[Code]...

How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!

View 10 Replies View Related

Security :: Interpreting Zenmap Results: Network Distance And Traceroute Hop Values

Apr 18, 2011

I ran two scans in Zenmap: 1) Quick scan plus and 2) Quick Traceroute. Quick scan plus, under the Nmap Output tab, has a field called "Network Distance". The Quick Traceroute report under the same tab lists the HOP and RTT time. I was thinking that for a given server, the value for the Network Distance would be the same as the HOP field when initiating the scans from the same server, but they are not.

View 5 Replies View Related

Programming :: Reading A Bash Variable In Bash Scripting ?

Nov 26, 2008

I have a config file that contains:

my.config:

Code:

Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.

Here is my parse_cmd script:

Code:

View 3 Replies View Related

Programming :: Run Multiple Bash And Php Scripts From A Bash Script?

Jul 25, 2011

I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.

Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?

View 5 Replies View Related

Programming :: Bash: Get Filename And Extension Using Bash?

Jan 9, 2010

I would like to get the filename (without extension) and the extension separately. The best solution I found so far is:

Let FILE="thefilenameofsomefilesfor_instance.txt"

Code:

NAME=`echo "$FILE" | cut -d'.' -f1`
EXTENSION=`echo "$FILE" | cut -d'.' -f2`

I think it would be better to count the len and remove 3 chars to right to get the extension, but it can be macintosh filenames with have 4 chars for extensions.

View 5 Replies View Related

Programming :: Replacing "slashes" With Back Slashes - Escape Character ?

Jan 7, 2011

Usually if I have to replace a character in a string I used the sed /s/ command. However, I am having some difficulty in doing the same thing when I have the following string in a variable in my shell script and I need to replace all the forward slashes ("/") to backslashes ("").

For example, this is what I am doing:

Code:

Not sure how to escape the slashes in this case.

View 2 Replies View Related

Programming :: Bash Programming - Rename Files In A Loop?

Mar 31, 2011

I need to rename the resulted searched files from a loopI have the following code:

find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done

basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell

View 10 Replies View Related

General :: Interpreting Output Of "du" Command?

Jun 24, 2010

I am trying to figure out the dir size of one of my dirs, and as far as I can tell the du command is the most appropriate for the job. However it doesn't appear to scan recursively correctly so I'm running the command independently on my 3 most important subfolders. One of them produces this output:

Code:
DiskStation> du -sh /volume1/video/MOVIES
16777215.1T/volume1/video/MOVIES

[code]....

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved