10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Linux System having all Perl, Python, PHP (and Ruby) installed
From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file
eg
eg
a Shell script run in a case statement call to run a php file, also Perl or/and Python file???
Like
#!/usr/bin/bash
....
....
case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
2. Programming
Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far:
#include<stdio.h>
#include<string.h>... (2 Replies)
Discussion started by: bjhjh
2 Replies
3. Shell Programming and Scripting
have written the below code to check whether the string received from user is a file name or dir using case statement, but its going into default case*).
#!/bin/sh
#Get a string from user and check whether its a existing filename or not
rm str2
rm str3
echo "enter a file \c"
read fil... (8 Replies)
Discussion started by: Mohan0509
8 Replies
4. Shell Programming and Scripting
I know this question is out there in many forums, but I tried all the combinations in vain.
I'm basically trying to call a sql script from a shell script.
Below is my sql script (plsql.sql)
DELCARE
v_empno NUMBER := '&empno';
BEGIN
select ename,sal from emp where empno = v_empno;... (3 Replies)
Discussion started by: FName_LName
3 Replies
5. Shell Programming and Scripting
I have directory path in which there are several sub directories. In all these sub dir there will be one env.cnf file. I want to copy this env.cnf file from
each sub dir's and place them in destination path by creating same filename as sub dir_env.cnf.
After copying env.cnf files from source... (4 Replies)
Discussion started by: Optimus81
4 Replies
6. Shell Programming and Scripting
Pls. advise how to find or used grep recursively all shell script files.
Some files doesnt have a .sh or .ksh extension name.
find / -name "*" |xargs grep bin |grep sh
??
TIA (1 Reply)
Discussion started by: budz26
1 Replies
7. Shell Programming and Scripting
Hi. I have a problem that i can't seem to resolve. I need to create a script that list all the files, that are found recursively, with the same name.
For example if a file exists in more than one directory with the same name it list all the files that he founds with all the info. Could someone... (5 Replies)
Discussion started by: KitFisto
5 Replies
8. Programming
Hi All,
How to call the C programme in UNIX shell scripting?
please send me some sample script for the above scenario.
Regards,
MPS:b: (1 Reply)
Discussion started by: psiva_arul
1 Replies
9. UNIX for Dummies Questions & Answers
Hello...I hava quite a problem, couldn't find a solution anywhere :(. I have a C program, and from that C program I have to call a shell script. This is not difficult, I can do it using the "system" command from C. But the ugly part is how can I send as parameters some variables? For example...i... (1 Reply)
Discussion started by: dustman
1 Replies
10. UNIX for Dummies Questions & Answers
How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Shell(3pm) Perl Programmers Reference Guide Shell(3pm)
NAME
Shell - run shell commands transparently within perl
SYNOPSIS
use Shell qw(cat ps cp);
$passwd = cat('</etc/passwd');
@pslines = ps('-ww'),
cp("/etc/passwd", "/tmp/passwd");
# object oriented
my $sh = Shell->new;
print $sh->ls('-l');
DESCRIPTION
Caveats
This package is included as a show case, illustrating a few Perl features. It shouldn't be used for production programs. Although it does
provide a simple interface for obtaining the standard output of arbitrary commands, there may be better ways of achieving what you need.
Running shell commands while obtaining standard output can be done with the "qx/STRING/" operator, or by calling "open" with a filename
expression that ends with "|", giving you the option to process one line at a time. If you don't need to process standard output at all,
you might use "system" (in preference of doing a print with the collected standard output).
Since Shell.pm and all of the aforementioned techniques use your system's shell to call some local command, none of them is portable across
different systems. Note, however, that there are several built in functions and library packages providing portable implementations of
functions operating on files, such as: "glob", "link" and "unlink", "mkdir" and "rmdir", "rename", "File::Compare", "File::Copy",
"File::Find" etc.
Using Shell.pm while importing "foo" creates a subroutine "foo" in the namespace of the importing package. Calling "foo" with arguments
"arg1", "arg2",... results in a shell command "foo arg1 arg2...", where the function name and the arguments are joined with a blank. (See
the subsection on Escaping magic characters.) Since the result is essentially a command line to be passed to the shell, your notion of
arguments to the Perl function is not necessarily identical to what the shell treats as a command line token, to be passed as an individual
argument to the program. Furthermore, note that this implies that "foo" is callable by file name only, which frequently depends on the
setting of the program's environment.
Creating a Shell object gives you the opportunity to call any command in the usual OO notation without requiring you to announce it in the
"use Shell" statement. Don't assume any additional semantics being associated with a Shell object: in no way is it similar to a shell
process with its environment or current working directory or any other setting.
Escaping Magic Characters
It is, in general, impossible to take care of quoting the shell's magic characters. For some obscure reason, however, Shell.pm quotes
apostrophes ("'") and backslashes ("") on UNIX, and spaces and quotes (""") on Windows.
Configuration
If you set $Shell::capture_stderr to 1, the module will attempt to capture the standard error output of the process as well. This is done
by adding "2>&1" to the command line, so don't try this on a system not supporting this redirection.
Setting $Shell::capture_stderr to -1 will send standard error to the bit bucket (i.e., the equivalent of adding "2>/dev/null" to the
command line). The same caveat regarding redirection applies.
If you set $Shell::raw to true no quoting whatsoever is done.
BUGS
Quoting should be off by default.
It isn't possible to call shell built in commands, but it can be done by using a workaround, e.g. shell( '-c', 'set' ).
Capturing standard error does not work on some systems (e.g. VMS).
AUTHOR
Date: Thu, 22 Sep 94 16:18:16 -0700
Message-Id: <9409222318.AA17072@scalpel.netlabs.com>
To: perl5-porters@isu.edu
From: Larry Wall <lwall@scalpel.netlabs.com>
Subject: a new module I just wrote
Here's one that'll whack your mind a little out.
#!/usr/bin/perl
use Shell;
$foo = echo("howdy", "<funny>", "world");
print $foo;
$passwd = cat("</etc/passwd");
print $passwd;
sub ps;
print ps -ww;
cp("/etc/passwd", "/etc/passwd.orig");
That's maybe too gonzo. It actually exports an AUTOLOAD to the current package (and uncovered a bug in Beta 3, by the way). Maybe the
usual usage should be
use Shell qw(echo cat ps cp);
Larry Wall
Changes by Jenda@Krynicky.cz and Dave Cottle <d.cottle@csc.canterbury.ac.nz>.
Changes for OO syntax and bug fixes by Casey West <casey@geeknest.com>.
$Shell::raw and pod rewrite by Wolfgang Laun.
Rewritten to use closures rather than "eval "string"" by Adriano Ferreira.
perl v5.12.1 2010-05-13 Shell(3pm)