both sides execution of command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting both sides execution of command
# 1  
Old 05-12-2011
both sides execution of command

Hi,

i am struggling with a chunk of code.

Code:
    for ((i=1; i<=3; i++));do
        one-$i ="/tmp/one.$RANDOM"
    done

How to execute the above code.
In both sides(LHS and RHS), i am executing commands.
it is not allowing to execute.

can you please give the idea.

It should be very appreciable, if i get an example.

Thanks.

Last edited by pludi; 05-12-2011 at 05:19 AM..
# 2  
Old 05-12-2011
what are you exactly trying here ?

Please help us with some explanation.
# 3  
Old 05-12-2011
I like to get the output as
one-1="/tmp/one.22345"
one-2="/tmp/one.22346"

I mean to say like, I want to intialize two variables, one-1 one-2 with respective values.
# 4  
Old 05-12-2011
one-$i ="/tmp/one.$RANDOM" Won't work
  1. use eval
  2. no space around '='
Code:
eval "one-$i=/tmp/one.$RANDOM"

# 5  
Old 05-12-2011
Quote:
Originally Posted by frans
one-$i ="/tmp/one.$RANDOM" Won't work
  1. use eval
  2. no space around '='
Code:
eval "one-$i=/tmp/one.$RANDOM"

Code:
sh-3.00# for ((i=1; i<=3; i++));do echo $(eval "one-$i=one.$RANDOM"); done
sh: one-1=one.13352: command not found

sh: one-2=one.14261: command not found

sh: one-3=one.15170: command not found

sh-3.00#

it is saying like command not found..
but it is not command
# 6  
Old 05-12-2011
Code:
$ for ((i=1; i<=3; i++));do eval "one_$i=one.$RANDOM" ; done
$ echo $one_1
one.21586
$ echo $one_2
one.22755
$ echo $one_3
one.17778

This worked for me. can you try this.

---------- Post updated at 04:05 PM ---------- Previous update was at 04:02 PM ----------

I just changed the '-' to '_', it is not interpreting the latter as a command. Not sure why.

I think bash variables shouldn't contain special chars other than '_'.

Because it neither worked with '.'
# 7  
Old 05-12-2011
Quote:
Originally Posted by kumaran_5555
(...)
I just changed the '-' to '_', it is not interpreting the latter as a command. Not sure why.
I think bash variables shouldn't contain special chars other than '_'.
Right. I should have seen that !
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution of command at command prompt

Hello Experts, I am still learning linux and have come across a question, hope to get some answer. I have two servers, and both have the same version of svn client installed and both have the same user_id. my SVN client version: svn, version 1.6.11 (r934486) compiled Mar 2 2011,... (4 Replies)
Discussion started by: babyPen1985
4 Replies

2. UNIX for Advanced & Expert Users

Parallel Execution of Command

Hi All, We have a table that has to store around 80-100 million records. The table is partitioned by a column called Market Code. There are 30 partitions each corresponding to one MRKT_CD. The source of this table is a join between 3-4 other tables. We are loading this table through SQLPLUS... (2 Replies)
Discussion started by: jerome_rajan
2 Replies

3. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

4. Shell Programming and Scripting

Want to terminate command execution when string found in the command output

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

5. AIX

HMC updates managed system firmware on both T and P sides ?

Hi, I'm planning to update managed system firmware to new release using HMC. This is cite from IBM documentation describing HMC managed system updates: What I know we install new firmware to T side and in case some problems we boot P side and reject new fw on T. So if HMC updates both T and... (0 Replies)
Discussion started by: vilius
0 Replies

6. Solaris

get the total execution of command

hi, i have to get the info between start to stop of a command execution suppose, if we execute the command like pkgadd then while its executing it ask some questions , i have to get total information untill pkgadd command complete into a perticular file. (3 Replies)
Discussion started by: shankr3
3 Replies

7. Shell Programming and Scripting

Code for execution command by command

a) cd /root/user/dir/sd/disk ./runInstaller -silent -responseFile b) cd /root1/user1 cp /root/user/dir/sd/disk/ram.txt now a) executes and starts running but b) interupts a) and is executed while a) is running on the other hand so I want b) to start only after successfull completion of... (6 Replies)
Discussion started by: sriki32
6 Replies

8. UNIX for Advanced & Expert Users

command execution alert

hi Guys! My requirement is... I need to get notified if somebody executes a specific commands...like kill or httpd stop.... something like that.... can somebody help me out... Regards, kiran (8 Replies)
Discussion started by: dddkiran
8 Replies

9. UNIX for Advanced & Expert Users

command execution ??

hi i have small shell script as follows cd /utilities/promoter/tmp grep SENDREPLY $1 | grep 'zzzzz@zzz.com' | awk -F" -f1 > /tmp/$LOGNAME/$1.request cd /tmp/$LOGNAME grep -e "\.sql" -e "\.md" $1.request > upd_$1.txt grep -v -e "\.sql" -e "\.md" $1.request > copy_$1.txt ... (1 Reply)
Discussion started by: zedex
1 Replies
Login or Register to Ask a Question