Sponsored Content
Top Forums Shell Programming and Scripting Please help: Build a sed command and execute it in a script Post 302216218 by gugs on Friday 18th of July 2008 08:46:34 AM
Old 07-18-2008
The code below works:

Range1="${keys[$i]}"
Range2="${keys[$i+1]}"
a="sed -n /"
b="/,/"
c="/p"
echo "$a$Range1$b$Range2$c" > temp1.txt
sedcmd=$(grep sed temp1.txt)
errordata=$($sedcmd < test1.txt)
echo "$errordata" > temp2.txt

However, I am having to echo the contents of the variable to a file which I process further.

What I would like to do is send the data from the $sedcmd < test1.txt to temp2.txt by using: cat test1.txt | $($sedcmd) > temp2.txt. However, this gives me 'No such file or directory' errorr Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: littlejon
1 Replies

2. Shell Programming and Scripting

how to execute a sh command from a csh script

Hi everyone, I have a csh script that works fine but the output of an rsh command is different if I use boune shell instead cshell. Is there the possibility to execute only this command in bourne shell from a script declared cshell? Thanks Christian (2 Replies)
Discussion started by: bonovox
2 Replies

3. Shell Programming and Scripting

How to build a command in a script

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

4. Shell Programming and Scripting

exec a build command (adduser) in a script

Hi, With a awk script i create a "adduser line" $ cat /tmp/tmp.ldif | awk -f ldif2adduser.awk adduser --uid 1002 --gid 1000 --gecos "ROUSSIN Guy" --home /homeL/guy --shell /bin/bash --disabled-password guy If i cut and paste this line, all is fine. But in a shell script i get errors : ... (2 Replies)
Discussion started by: guyr
2 Replies

5. Shell Programming and Scripting

Execute sed altered script

Man...no one answered my last two posts...Oh well, so hey guys i have a script that i'm wanting to put a # on a certain line, and then execute the script but not write it to the script. So far I'm doing it the dirty way with: sed -i -e "s/^rm/\#rm/" -e "s/^tar/\#tar/" /path/to/file ... (3 Replies)
Discussion started by: DC Slick
3 Replies

6. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

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

7. Shell Programming and Scripting

Script runs but does not execute rm -rf command

Hi! First off I'm no bin/bash script writer! :( I can make heads and tales of it from the php experience I have and that's all. Now I managed to piece this script together to go look at directory and remove files that are +60 days. It's finding the files but its not removing them. I... (11 Replies)
Discussion started by: MrBiggz
11 Replies

8. Shell Programming and Scripting

Build.xml invocation by Build Script

Hi I have a build.xml file and I can run it on Windows via cmd. Now I want to write a script to invoke the same. Is there a way to do this? (1 Reply)
Discussion started by: ankur328
1 Replies

9. Shell Programming and Scripting

sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns. When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns. sed -i 's/$/\r/' lf_file.txt But that same... (1 Reply)
Discussion started by: hawkman2k
1 Replies

10. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

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
libssh2_agent_get_identity(3)					  libssh2 manual				     libssh2_agent_get_identity(3)

NAME
libssh2_agent_get_identity - get a public key off the collection of public keys managed by ssh-agent SYNOPSIS
#include <libssh2.h> int libssh2_agent_get_identity(LIBSSH2_AGENT *agent, struct libssh2_agent_publickey **store, struct libssh2_agent_publickey *prev); DESCRIPTION
libssh2_agent_get_identity(3) allows an application to iterate over all public keys in the collection managed by ssh-agent. store should point to a pointer that gets filled in to point to the public key data. prev is a pointer to a previous 'struct libssh2_agent_publickey' as returned by a previous invoke of this function, or NULL to get the first entry in the internal collection. RETURN VALUE
Returns 0 if everything is fine and information about a host was stored in the store struct. Returns 1 if it reached the end of public keys. Returns negative values for error AVAILABILITY
Added in libssh2 1.2 SEE ALSO
libssh2_agent_list_identities(3) libssh2_agent_userauth(3) libssh2 1.2 23 Dec 2009 libssh2_agent_get_identity(3)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy