shell

Installing sSMTP from SSH

I'm on a Web Hosting Buzz reseller account. They have some very stringent mail sending rules, including blocking of authenticated SMTP socket mail sending using PEAR. It was suggested in WHB forum that this was possible with sSMTP. I've since gotten SSH access and googled how to install sSMTP from SSH: rpm -Uvh http://download.fedora.re...

Start a job that does not end when my terminal session does?

How can I start a job on a *nix system that will not exit when my session exits? ...

How to provide metadata tags,keywords to Windows and fill properties page for a custom file format?

Hi, My application uses its own file format (compressed SQLite databases) to store user created data. 1) I would like to know how to provide keywords, tags to Windows so that Vista search function can include my file format when indexing. 2) I would like to provide a properties page like you see when you right click a Microsoft Word ...

Recursive FTP directory listing in shell/bash with a single session (using cURL or ftp)

I am writing a little shellscript that needs to go through all folders and files on an ftp server (recursively). So far everything works fine using cURL - but it's pretty slow, becuase cURL starts a new session for every command. So for 500 directories, cURL preforms 500 logins. Does anybody know, whether I can stay logged in using cUR...

Creating folders using Android SDK

Is it possible to be able to create a folder on the sd card of the phone via using Android SDK or the Shell? ...

How prevalent is the use of Emacs' eshell in multi-platform development?

I've only recently become aware of Emacs' eshell tool. It looks quite powerful in that it is entirely written in Emacs Lisp and does not require native subshell support. The Emacs info documentation is a bit sparse but EmacsWiki has pretty decent information, at least on a first glance. Given the potential value of eshell as a scripti...

Controlling shell command line wildcard expansion in C or C++

I'm writing a program, foo, in C++. It's typically invoked on the command line like this: foo *.txt My main() receives the arguments in the normal way. On many systems, argv[1] is literally *.txt, and I have to call system routines to do the wildcard expansion. On Unix systems, however, the shell expands the wildcard before invokin...

How to kill all subprocesses of shell?

I'm writing bash script, which does several thing. In the beginning it starts several monitor scripts, each of them runs some other tools. At the end of my main script, I would like to kill all things that spawned from my shell. So, it might looks like this: #!/bin/bash some_monitor1.sh & some_monitor2.sh & some_monitor3.sh & do_so...

How to use find command to find all files with extensions from list?

Hello, I need to find all image files from directory (gif, png, jpg, jpeg). find /path/to/ -name "*.jpg" > log How to modify this string to find not only .jpg files? Thank you. PS: Unix ...

How to check that all files from STDOUT are present on remote host? (via SSH)

Hello, Let's imagine that I have list of files at host1 find /path/to -name "*.jpg" -print I want to connect to host2 via SSH and check that all files from this list are present on remote host. Please help, how can I do this? Thank you ...

execute adb shell command at runtime from the android application

hi. In my application I want to create a directory xyz in sdcard at the runtime from the my Application. But it doesn't work. Here is my code.. public class process extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState)...

Detect number of IDLE processors ruby

Hello, I work on shared linux machines with between 4 and 24 cores. To make best use of them, I use the following code to detect the number of processors from my ruby scripts: return `cat /proc/cpuinfo | grep processor | wc -l`.to_i (perhaps there is a pure-ruby way of doing this?) But sometimes a colleague is using six or eight of t...

Why Does Piping Binary Text to the Screen often Horck a Terminal

Imaginary Situation: You’ve used mysqldump to create a backup of a mysql database. This database has columns that are blobs. That means your “text” dump files contains both strings and binary data (binary data stored as strings?) If you cat this file to the screen $ cat dump.mysql you’ll often get unexpected results. The terminal ...

Safe executing shell scripts; escaping vars before execution.

Hello, Let's imagine that we have a simple php script that should get ssh_host, ssh_username, ssh_port from $_GET array and try to connect using this parameters to SSH. $port = escapeshellcmd($_GET['ssh_port']); $host = escapeshellcmd($_GET['ssh_host']); $username = escapeshellcmd($_GET['ssh_username']); $answer = shell_exe...

Bash: Terminate on Timeout/File Overflow while Executing Command

I'm writing a mock-grading script in bash. It's supposed to execute a C program which will give some output (which I redirect to a file.) I'm trying to (1) make it timeout after a certain duration and also (2) terminate if the output file reaches a certain file size limit. Not sure how to go about either of these. Any help? Thanks. ...

How do I write one-liner script that inserts the contents of one file to another file?

Say I have file A, in middle of which have a tag string "#INSERT_HERE#". I want to put the whole content of file B to that position of file A. I tried using pipe to concatenate those contents, but I wonder if there is more advanced one-line script to handle it. ...

get a list of function names in a shell script

I have a Bourne Shell script that has several functions in it, and allows to be called in the following way: my.sh <func_name> <param1> <param2> Inside func_name() will be called with param1 and param2. I want to create a "help" function that would just list all available functions, even without parameters. The question: how do I ge...

How to write scripts that can run in bash and csh?

I'm not sure if this is even possible, but is there a way to write shell scripts that can be interpreted by both the Bourne shell as well as C shell? I want to avoid simply checking for the shell and running a shell-specific code. If this is possible, are there any guides on how to do it? I have always written my scripts for Bourne shel...

what is the difference between "./somescript.sh" and ". ./somescript.sh"

This question may sounds silly to you. Today I was following some instructions to install a software in Linux. There was a script that needs to be run first. It set some environment variables. The instruction told me to execute . ./setup.sh, but I made a mistake by executing ./setup.sh. So the env was not set. Finally I noticed this an...

I am new to shell scripting and i have wriiten a script to flag values within a if loop but if i try to call those values in another if loop it is returning null values

#!/bin/sh cat PLAYARTE_TXT.txt|while read line do count1=$(echo $line|wc -c) a=37 if [[ $count1 -eq $a ]]; then b=0 else c=1 break fi done if [ "$b" -eq "0" -a "$c" -ne "1" ]; then echo success else echo failure fi exit 0 ...