Computing.Net > Forums > Unix > two variable input from the same fi

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

two variable input from the same fi

Reply to Message Icon

Name: shilpa kulkarni
Date: May 5, 2003 at 02:46:08 Pacific
OS: unix
CPU/Ram: p4
Comment:

Hi all,
I am trying to run the command:
kickstart -w $so -t $task -c Close
for the file which contains data as follows:
SO20031201005571 3EB5F70C00000000548C7026
SO20031241021097 3EB5E4EA0000000054927026
SO20031241021143 3EB5E4F30000000054907026
SO20031221015061 3EB2573F0000000042927026 This sodata file contains two fields 1 st field contains value for $so and 2nd field with tab delimiter contains $task value. I tried this with using two for loops but it is unable to take two variables at a time in one command line which I require.
Pl. can anybody will give me solution to this ? Is this necessary to use two for loops? two variables can not use in one for loop?




Sponsored Link
Ads by Google

Response Number 1
Name: LANkrypt0
Date: May 5, 2003 at 06:09:54 Pacific
Reply:

This script worked fine for me. Uses an until loop so it can adjust for different file size. This script assumes it has 3 files, the datatfile, the kickstart file and this file.

All you would need to change in there is where it says dtf=datafile, just change datafile to the actual datatfle name.

#!/bin/ksh
dtf=datafile

x=1
until [[ $x -gt `wc -l $dtf | awk '{print $1}'` ]];do
so=`head -$x $dtf|tail -1|awk '{print $1}'`
task=`head -$x $dtf|tail -1|awk '{print $2}'`
kickstart -w $so -t $task -c Close
x=$(($x+1))
done


0

Response Number 2
Name: nails
Date: May 5, 2003 at 08:03:29 Pacific
Reply:

Hi:

Given: a data file with two columns tab-delimited:

Why not let the shell do the parsing?

#!/bin/ksh

while read so task
do
kickstart -w $so -t $task -c Close
done data.file
# end script
# this forum wipes out the less than sign
# between the done and data.file

Regards,

Nails


0

Response Number 3
Name: LANkrypt0
Date: May 5, 2003 at 23:10:54 Pacific
Reply:

Thank u friend !!!
Below script worked out and I got the result excepted.
thanks again .
shilpa
#!/bin/ksh
dtf=datafile

x=1
until [[ $x -gt `wc -l $dtf | awk '{print $1}'` ]];do
so=`head -$x $dtf|tail -1|awk '{print $1}'`
task=`head -$x $dtf|tail -1|awk '{print $2}'`
kickstart -w $so -t $task -c Close
x=$(($x+1))
done



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: two variable input from the same fi

Taking input from file and user www.computing.net/answers/unix/taking-input-from-file-and-user/6752.html

how can i get the input from user www.computing.net/answers/unix/how-can-i-get-the-input-from-user/5641.html

Shared Libraries with the same name www.computing.net/answers/unix/shared-libraries-with-the-same-name/7589.html