05-29-2008
How to build a command into a string rather than execute the command
I'm trying to populate a command line into a variable. It appears to be executing, instead. Here's an example:
mycmd=''
if ...; then
$mycmd='sudo '
fi
$mycmd=$mycmd 'sed -i prev s/aaa/bbb/' $myfile
res=`$mycmd`
(I'm also not sure of the best way to execute the command from the variable, either, so any corrections would be appreciated!)
Last edited by littlejon; 05-29-2008 at 08:56 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi Group ,
I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages.
- i m writing
>write user-id
! ls
o
ctrl-d
inspite of executing the command ls,other terminal shows ! ls.
Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies
2. Shell Programming and Scripting
my description from another thread...
here's my code:
#!/bin/bash
IFS=$'\n'
function OutputName() {
input=$1
echo $input
input=`echo "$input" | sed -e 's/.//'`
input=`echo "$input".avi`
output_name=$input
}
if ]; then
echo... (5 Replies)
Discussion started by: TinCanFury
5 Replies
3. Shell Programming and Scripting
I am using an array to store some data (keys e.g 47975081_1215781266128), it can be assumed that it is key to other data.
I want extract data from a file based on a couple of keys (range) and store the resulting data in a variable using the following command:
sed -n... (9 Replies)
Discussion started by: gugs
9 Replies
4. Shell Programming and Scripting
Hello everyone.
I am using the select command to build a menu, here is my question:
Is it possible to generate a menu which contains several sections and have a separator between the sections without having a selection number generated in front of the separator?
This is a sample of what I would... (1 Reply)
Discussion started by: gio001
1 Replies
5. Shell Programming and Scripting
Hi All
I am trying to build a script that will take data from a tab separated file and use that to split up a quicktime file. So far the code is as follows
#!/bin/sh
#test parsing of data
#fix excel file output returns
cat $1 | tr "\r" "\n" > $1.fix
printf "\n" >> $1.fix
mv $1.fix $1
... (3 Replies)
Discussion started by: babajuma
3 Replies
6. Shell Programming and Scripting
Hi,
Here's the problem I am facing.
This is just an example:
list_files.ksh
------------
dir=$1
match=$2
var="ls $dir | grep $match"
files=`"$var"`
I get the below error on executing the above script:
./list_files.ksh: ls /home/my_files | grep xml: not found
I know I... (2 Replies)
Discussion started by: dips_ag
2 Replies
7. Shell Programming and Scripting
I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found"
My code is as follows:
--------------------------
#!/bin/sh
user="test"
DIR="/bldtmp/"$user
VIEW="test.view1"
echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies
8. Shell Programming and Scripting
Hi Experts,
I am very much new to linux scripting, I am currently working on reducing my manual work and hence writing a script to automate few task.
I am running below command to snmpwalk the router..
snmpwalk -v 3 -u WANDL_SU -a MD5 -A vfipmpls -x DES -X VfIpMpLs -l authPriv... (19 Replies)
Discussion started by: Hanumant.madane
19 Replies
9. Shell Programming and Scripting
Hello :)
new to bash not to programming.
I have an on-going need to change the owning group on sets of files and directories from the one they were created with or changed to on update to the one they need to have going forward.
find {target_root} -group wrong_group
gets me a newline... (4 Replies)
Discussion started by: naftali
4 Replies
10. Shell Programming and Scripting
Hello i am having an issue with bash script and this is the code
now=$(cat hosts1.txt | awk '{print $2;}')
while read n ;do
ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers'
When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies
LEARN ABOUT DEBIAN
db_command
DB_COMMAND(9) BSD Kernel Developer's Manual DB_COMMAND(9)
NAME
DB_COMMAND, DB_SHOW_COMMAND, DB_SHOW_ALL_COMMAND -- Extends the ddb command set.
SYNOPSIS
#include <ddb/ddb.h>
DB_COMMAND(command_name, command_function);
DB_SHOW_COMMAND(command_name, command_function);
DB_SHOW_ALL_COMMAND(command_name, command_function);
DESCRIPTION
The DB_COMMAND() macro adds command_name to the list of top-level commands. Invoking command_name from ddb will call command_function.
The DB_SHOW_COMMAND() and DB_SHOW_ALL_COMMAND() are roughly equivalent to DB_COMMAND() but in these cases, command_name is a sub-command of
the ddb show command and show all command, respectively.
The general command syntax: command[/modifier] address[,count], translates into the following parameters for command_function:
addr The address passed to the command as an argument.
have_addr A boolean value that is true if the addr field is valid.
count The number of quad words starting at offset addr that the command must process.
modif A pointer to the string of modifiers. That is, a series of symbols used to pass some options to the command. For example, the
examine command will display words in decimal form if it is passed the modifier "d".
EXAMPLE
In your module, the command is declared as:
DB_COMMAND(mycmd, my_cmd_func)
{
if (have_addr)
db_printf("Calling my command with address %p
", addr);
}
Then, when in ddb:
db> mycmd 0x1000
Calling my command with address 0x1000
db>
SEE ALSO
ddb(4)
AUTHOR
This manual page was written by Guillaume Ballet <gballet@gmail.com>.
BSD
August 27, 2008 BSD