shell

Getting user to authenticate the password

I'm trying to write a sh coding to get the user to authenticate the password by comparing the user input to the first 32 characters of a file. So basically if the password is correct it would run TaskMenu.csh if its wrong the program would exit. #!/bin/sh clear echo -e " Please Enter the Password to access the TaskMenu:" read PW if (! -...

How to programmatically move windows taskbar (take two)

Hello. First of all, i know there is a similarly phrased question in SO, but it hasn't been answered properly, and most of the discussion around it fell unto the "you shouldn't be doing that". So lets start by the basics. Why this is needed. I work on a company that handed out a few dozen tablet netbooks to our workers. As you know, n...

IDLE like interactive console for Ruby

I'm starting out with Ruby and was wondering if there's an interactive console similar to Python's IDLE, you know, with context highlighting and autocompletion. I've tried IRB, but it's fairly spartan (although it gets the work done; no question about that). Googling hasn't helped. You guys have any suggestions? ...

VIM: Using custom functions as parameters for shell

I have the following code in a vim file that it's auto sourced when editing php files. But I can't make it work. "PHP config if !exists("g:addPath") let g:addPath = 1 let $PATH=$PATH.';C:\Program Files\Mozilla Firefox' endif function! MakeThisUrl() let s:url='http://localhost/' let s:url=s:url. expand('%') return s:url endfu...

what is the best way to find a subset of a list with grep?

My current solution: #!/bin/sh while read file2 do grep $file2 file1 done the contents of file1 will be something like: atlanta,blue,20090805 newyork,blue,20090805 washington,blue,20090805 dallas,blue,20090805 jacksonville,blue,20090805 the contents of file2 will be something like: newyork dallas jacksonville and the desired out...

Reading a specific line of a file

What is the best way (better performance) to read a specific line of a file? Currently, I'm using the following command line: head -line_number file_name | tail -1 ps.: preferentially, using shell tools. ...

check if file exists

#!/bin/ksh file_name=/home/file2.sh used_var=`grep "poet" $file_name` I want to check if file2.sh exists and also if used_var has some value or it has nothing. ...

How to save "history" automatically depending on the directory

Hi, I work extensively using the shell. When I continue working on some project one week later, I go to some "folder" and realize that I do not remember what I was doing. Sometimes and before stopping work what I do is: history > DIRX_HISTORY_20100922 so later I have a look at the commands I used, I can remember much better what I w...

Find a file and open it for editing. How to do it fast in a bash shell ?

I face many times this simple and repetitive task configuring the LAMP or some stuff in Ubuntu or Drupal: I have to edit a config file (php.ini, httpd.conf, ... whatever) so quite frequently, if I don't remember the path by heart, I run these 2 commands: locate php.ini ------- typing manually one of the paths that are shown in the list...

xargs with multiple arguments

I have a source input, input.txt a.txt b.txt c.txt I want to feed these input into a program as the following: my-program --file=a.txt --file=b.txt --file=c.txt So I try to use xargs, but with no luck. cat input.txt | xargs -i echo "my-program --file"{} It gives my-program --file=a.txt my-program --file=b.txt my-program --file=...

How can I enable ctrl-c / ctrl+break after calling system?

I have written a program that invokes a system command from inside: #include <stdlib.h> int main(void) { while(1) { system("ls 2>&1 1>/dev/null"); // comment this line out to enable ctrl+break } return 0; } However, when it is running, CTRL+C and CTRL+BREAK no longer work and appear to be ignored. I am tryin...

Nmap in a bash script / only check the "80" open ports...

Hi, I'm completely new to bash scripting and I'm trying to get this working: Scanning an ip range for finding devices with the port 80 open... I think it has to look like this: #!/bin/bash echo ----------------------------------- for ip in 192.168.0.{1,.255}; do nmap -p80 192.168.0.1 if #open; then echo "{ip} has the ...

Is it possible to build a interactive C shell?

I'm just wondering if this is possible using either (Python, Java or C)? I'm looking for something like IPython for Python. ...

What command do you use to preview any image

I'm trying to write a command in sh using the software ImageMagick. I was trying to find a command that allows me use any image( presumably jpeg) and be able to preview the image but at a 200x200 pixels instead of the original size? ...

How to access Windows shell context menu items?

Hi, In Windows Explorer, you right click on a file, a context menu shows up which contains built-in items like 'Send to...' and/or 3rd party actions such as 'zip file with Winzip'. My question are: How to obtain the full list of available menu items for a specific file? For each menu item, how to get the caption? How to invoke a speci...

preview multiple thumbnails of images

I have this piece of sh code here which takes one argument at a time: #!/bin/sh clear if [ $# -eq 0 ] then echo -n "There are arguments...Please enter again with the arguments" echo exit elif [ ! -f "$*" ] then echo -n "The image file '$*' doesn't exist!" ...

requestAction() does not go to the controller's function after beforeFilter(), from a shell class

Hi, In my CakePHP aplication, I use a shell script with a cron job which is working perfectly, except when it comes to call the requestAction() function. Thanks to my logs, I can see it going to the proper Controller->beforeFilter() function, but after that nothing happens. It neves goes into the specific function. I tried to output $t...

Is it possible to enable ERASE while in non-canonical mode?

The question is pretty much in the title. I need to have my terminal in non-canonical mode for some input I am getting from the user (I need to have Ctrl-D act as an immediate "finished" signal, rather than flushing the input when pressed and only EOF-ing when there is no input to flush.), but this makes it impossible to ERASE. I am not ...

creating tidy shell script from ugly command line pipeline

Hi I wrote a piped shell command that has multiple pipes in it that works great. I now want to put this in the form of a (tidy) shell script. Here is the script: #!/bin/bash for number in `cat xmlEventLog_2010-03-23T* | sed -nr "/<event eventTimestamp/,/<\/event>/ {/event /{s/^.*$/\n/; p};/payloadType / {h; /protocol/ {s/.*protocol=\"(...

shell script remote execution using python

Is there a way that I can use Python on Windows to execute shell scripts which are located on a remote Unix machine? P.S: Sorry about the late edit. I do know of Paramiko, but I wanted to know if there is way of doing it without it. For starters, could it be done with subprocess()? ...