shell

open failed: No such file or directory

I have built a standalone executable which references my .so object. both are in the same directory. when I try to run executable it gives me the following error: ld.so.1: myExec: fatal: libMine.so: open failed: No such file or directory what am I doing wrong? ...

Why reference $? explicitly

A lot of sh code looks like: $cmd if [ $? = 0 ]; then $cmd2; fi Instead of: if $cmd; then $cmd2; fi I have typically assumed that people use the former simply because they are unaware that the syntax of the latter is valid, but I'm wondering if there is another reason (although the only possibility that comes to mind is portabili...

Have SSH login session redirect to interactive telnet to localhost instead

I am developing for a system that has an interactive telnet management console. Requirements dictate that we disable telnet access and add SSH instead. Changing the management console into a stand-alone program that we can use for SSH login would require a vendor to get involved. I was thinking of a less expensive solution that would ...

Linux command to do wild card matching

Is there any bash command to do something similar to: if [[ $string =~ $pattern ]] but that it works with simple wild cards (?,*) and not complex regular expressions ?? More info: I have a config file (a sort of .ini-like file) where each line is composed of a wild card pattern and some other data. For any given input string that ...

Execve problem with invoking

Why it doesn't work :( I want to simply invoke a shell in C program by execve: #include <stdio.h> #include <stdlib.h> #include <errno.h> main() { char* path = "/bin/sh"; int err = execve(path, &path, NULL); printf("%d\n", err); printf("%s\n", strerror(errno)); printf("%x, %x\n", path, &path); } ...

Unix "wrap" filter

is there one? something I could use like this: $ cat someFileWithLongLines.txt | wrap -80 --indent|less ...

Why does my process counting script give false positives?

I have the following bash script, that lists the current number of httpd processes, and if it is over 60, it should email me. This works 80% of the time but for some reason sometimes it emails me anyways when it is not over 60. Any ideas? #!/bin/bash lines=`ps -ef|grep httpd| wc -l` if [ "$lines" -gt "60" ] then mailx -s "Over 6...

Using logical OR (||) in C-Shell

I have a C-Shell code where I use the following command: if($#arr == 0 || $arr[1] == "test1") then It outputs an error message saying "tcsh: arr: Subscript out of range." obviously because the first condition is true. Is it possible to force it to ignore the second condition if the first condition is true? ...

Shell Scripting error

Hi, I'm very new to shell scripting and i've been struggling with the following shell script. I'm posting the script and the commands i used below for your consideration please help me with the mistake i made. # # # DBG=0 RLS=0 ALL=0 CLN=0 print_help_uu() { echo "Usage: $0 -D -R -A -C "; echo "Where -C clean the deb...

command line byte sequence

How do you express a byte sequence from the command line? i.e like you would in PHP with the following: <?php echo "\xC2\xA3" usage: for passing a Unicode string to a script or program. The above example is the UK pound sign "£" ...

Running Shell scripts through java

So I have a java class that takes individual commands and puts them into the shell through the Runtime and Process objects. My problem is that I can run a command like: $ls /users/me/documents and it will work, but $cd /users/me/documents $ls still lists the root. Obviously the Process and runtime objects don't keep track of whe...

Cannot SCP a path with spaces from bash script?

I have a bash script which generates an SCP command to execute. The relevant parts of the code look like this: echo $COPY_CMD $COPY_CMD My output looks like this: rascher@localhost:~/Desktop/video_final$ ./xfervids.sh scp "/media/My Book/PhotosVideos/Videos/18May2008Download/SD_VIDEO/PRG001/MOV056.MOD" [email protected]:./video...

How to reproduce "Show in Folder" / "Find Target" via C#

When using Chrome, if you download a file you can then choose an option (Show in Folder) which will open the containing directory and highlight the file. Similarly, if you view the properties of a shortcut you can choose the "Find Target" button for that same functionality. I have tried numerous searches, as well as looking over a dece...

bourne shell single-quote, doublequote & backquote question

Hi all, #/!bin/sh if [ "`echo $desc $status | awk -F"," '{print $3}' | awk -F" " '{print $1}' | sed '/^$/d'`" != "OK" ]; then echo "howdy dody" fi echo $desc $status | awk -F"," '{print $3}' | awk -F" " '{print $1}' | sed '/^$/d' First if-condition won't run, im guessing it's because of improper quotation, but i can't ...

Include one file to another

I'm looking for very simple template script for building JS files. It should do only one thing: include one file to another. Template (main.js) /*> script.js */ var style = "/*> style.css */"; script.js var my_script; style.css html, body {margin:0; padding:0} .my-style {background: #fffacc} Output var my_script; var style =...

Shell menu item separator

Hello friends, My question may be the repeated one here but even after googling i havn't got the solution yet. I have added a shell context menu item for files i.e. when you right click on a file within explorer the menu shows my custom menu item. I have used - HKLM\Software\Classes*\shell\myappname HKLM\Software\Classes*\shell\mya...

Bash combine two arrays

I have the following situation, two arrays, let's call them A( 0 1 ) and B ( 1 2 ), i need to combine them in a new array C ( 0:1 0:2 1:1 1:2 ), the latest bit i've come up with is this loop: for ((z = 0; z <= ${#A[@]}; z++)) do for ((y = 0; y <= ${#B[@]}; y++)) do C[$y + $z]="$...

Batch script to take backup of all *.c and *.h files.

I am new to MS batch programing. I want to copy files with matching regex to destination with same directory structure. If I use dir /b /s, I get full path of source then how can I get the relative path from source path? I want DOS based batch script equivalent of something like this in bash script, file_list=`find ./abc/test -nam...

How to create a reflection Effect using ImageMagick?

What would be the command to create a reflection effect using ImageMagick which fades out as a gradient. Like shown in http://reflection.corephp.co.uk/gfx/shot.jpg ...

Difference between test -h and test -L

What is the difference between test -L filename and test -h filename in ksh shell. From the man page, both were used to identify a symbolic link, but I want to know the exact difference. Here is the description from the man page. -h file True if file exists and is a sym- bolic link. -L file...