• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

BASH> Set DELETE key in Putty/Poderosa/SecureCRT

Oct26
2010
Written by Scott Rowley

For Poderosa/Putty
– Create or edit the ~/.inputrc file with the following code:

"\e[3~": delete-char

For SecureCRT

Click Tools
Keymap Editor
Click the "DEL" button
Click Map Selected Key
enter in "\e[3~" (no quotes)
Hit OK
Save
Posted in BASH - Tagged delete, key, poderosa, putty, securecrt, terminal

Emacs> Set delete key in emacs

Oct26
2010
Written by Scott Rowley

I really hate that the delete key backspaces. I’m sure there is a lot of pointless posturing on how this is the ‘old school’ way. Well… 1) I don’t care 2) I’m new school and I want a backspace key AND a delete key…
Add the following line to your ~/.emacs file:

(global-set-key (kbd "") 'delete-char)
Posted in Emacs - Tagged backspace, BASH, delete, Emacs, key

BASH> Run command from root as another user

Oct26
2010
Written by Scott Rowley

Every once in a awhile you may find you need to run a command as a different user than yourself. In order to do so you will first need to be root, then perform the following:

su <username> -c '<command1>; <command2>;'
Posted in BASH - Tagged BASH, command, root, su, user

BASH> Redirect output to standard out AND file

Oct26
2010
Written by Scott Rowley

Eventually in scripting you are likely to want to output to both the screen (standard out) and to a file. This makes it convenient to see whats getting “logged” without needing the extra step of cat’ing the file.

For example:

ls -al | tee ls_al_result.txt

This will give you your normal ‘ls -al’ results but also feed them to your new file.

Posted in BASH - Tagged BASH, ls, redirect, standard out, tee

BASH> Tail multiple files & highlight

Oct26
2010
Written by Scott Rowley

Tail multiple files at once:

tail -f log1.log log2.log

If you want to highlight something when doing ‘tail -f’ you can use the following command:

tail -f /var/log/logfile | perl -p -e 's/(SEARCH)/33[7;1m$133[0m/g;'

Or if your terminal supports colours, such as linux terminal, you can use this:

tail -f /var/log/logfile | perl -p -e 's/(SEARCH)/33[46;1m$133[0m/g;'

And if you want it to beep (annoy you!) on a match use this:

tail -f /var/log/logfile | perl -p -e 's/(SEARCH)/33[46;1m$133[0m07/g;'

Another option using sed instead:

tail -f /var/log/logfile | sed "s/(SEARCH)/^[[46;1m1^[[0m/g"

Note that in the last example you have to actually type “cntl-v cntl-[” in place of “^[”

For a full list of control characters on Linux see:

man console_codes
Posted in BASH - Tagged BASH, highlight, sed, tail

osTicket> Allow clients to assign department

Oct26
2010
Written by Scott Rowley

This is the MOD for the much requested “Allow user to select department”…

Open $TICKETS_HOME/open.php
Remove

$_POST['deptId']=

(only this, not the rest of the line)

Open $TICKETS_HOME/include/client/open.inc.php
Before the Subject
insert the following:

<td align="left"><b>Department:</b></td>
<td>
<select name="deptId">
<option value="" selected >Select Department</option>
<?
$services= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.' ORDER BY dept_name');
while (list($deptId,$dept) = db_fetch_row($services)){
$selected = ($info['deptId']==$deptId)?'selected':''; ?>
<option value="<?=$deptId?>"<?=$selected?>><?=$dept?></option>
<?
}?>
</select>
&nbsp;<font class="error"><b>*</b>&nbsp;<?=$errors['deptId']?></font>
</td>
</tr>
Posted in osTicket - Tagged department, mod, modification, osTicket, ticket

Web Dev> CGI-based redirect

Oct26
2010
Written by Scott Rowley

Recently I replaced an old .cgi file with a shiny new .php page. I realize everyone is still linking to the old .cgi file so I had need to forward them all onto the sexy new page. This can be accomplished as easily as the following:

Simply replace (after backing up) your .cgi file with the following contents

#!/path/to/perl
print "Location: http://domain.com/newpage.php\n\n";
Posted in Web Development - Tagged cgi, code, Perl, Web Development

Javascript> Reference Javascript (.js) file

Oct26
2010
Written by Scott Rowley

Sometimes we have so much javascript code in our files that it just becomes bulky and gets in the way. Instead of including it all in your file, save it all to a seperate file that can be referenced in your page (or better yet multiple pages).
Simply place the following within your <head> tags:

<script language="javascript" src="/path/to/file.js"></script>
Posted in Javascript, Web Development - Tagged code, Javascript, reference, Web Development
Newer Entries »

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top