[ilugd] Bash Script: Parse a command output value into an array
Hi, I am trying to parse a set of space separated values from a file into an array in a bash script. Thing is my individual values can also have spaces between them hence each value is enclosed in double quotes. But the problem is i am unable to parse them properly into an array. After a bit of effort my problem boils down to the difference between following 2 scenarios. $ TESTARR=(abc def ghi) $ echo ${TESTARR[0]} $ echo ${TESTARR[1]} This correctly prints: abc def ghi However $ TESTARR=(`echo \abc def\ ghi`) $ echo ${TESTARR[0]} $ echo ${TESTARR[1]} This incorrectly prints: abc def I guess i am missing something very basic. I would be glad if you could suggest the correct way/way out. -- Puneet http://sahyog.blogspot.com/ Latest Post: Tutorial on SVN setup and usage ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] Bash Script: Parse a command output value into an array
On Wed, 2008-01-30 at 15:36 +0530, Puneet Lakhina wrote: [...] However $ TESTARR=(`echo \abc def\ ghi`) $ echo ${TESTARR[0]} $ echo ${TESTARR[1]} This incorrectly prints: abc def [...] What you want is probably eval TESTARR=(`echo \abc def\ ghi`) I would also suggest moving to a better scripting language like Python or Perl. Regards, Gora ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] Bash Script: Parse a command output value into an array
On Jan 30, 2008 3:44 PM, Gora Mohanty [EMAIL PROTECTED] wrote: On Wed, 2008-01-30 at 15:36 +0530, Puneet Lakhina wrote: [...] However $ TESTARR=(`echo \abc def\ ghi`) $ echo ${TESTARR[0]} $ echo ${TESTARR[1]} This incorrectly prints: abc def [...] What you want is probably eval TESTARR=(`echo \abc def\ ghi`) Thanks this works. But how exactly does it work? I mean how does eval change whats assigned to TESTARR? I would also suggest moving to a better scripting language like Python or Perl. Have been thinking of the same thing and trying to push the idea upstairs. Lets see when I get to type python on the AIX machine that I do this scripting on. :) Regards, Gora ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22/23, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/ -- Puneet http://sahyog.blogspot.com/ Latest Post: Tutorial on SVN setup and usage ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22-24, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] Bash Script: Parse a command output value into an array
On Thu, 2008-01-31 at 00:44 +0530, Puneet Lakhina wrote: On Jan 30, 2008 3:44 PM, Gora Mohanty [EMAIL PROTECTED] wrote: [...] What you want is probably eval TESTARR=(`echo \abc def\ ghi`) Thanks this works. But how exactly does it work? I mean how does eval change whats assigned to TESTARR? It has to do with the order of evaluation. 'eval' first concatenates all tokens, and then evaluates the expression. Here is what is probably the canonical example of the use of eval: num=10 x=foo Now, note the difference between, y='$'$x echo $y and, eval y='$'$x echo $y [...] Have been thinking of the same thing and trying to push the idea upstairs. Lets see when I get to type python on the AIX machine that I do this scripting on. :) [...] http://docs.python.org, man perlintro, man perltoc. Regards, Gora P.S. By the way, AIX is UNIX on crack. ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22-24, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] Need help to Enable VINO Remotely in Ubuntu
On Jan 30, 2008 8:50 AM, Kristian Erik Hermansen [EMAIL PROTECTED] wrote: On Jan 29, 2008 7:01 PM, Smruti [EMAIL PROTECTED] wrote: Hi All, Thanks for responding to the mail so quick. Well, now i am facing some more problems. I am only able to login when one of the user is logged into the system through on the local system; i;e using the gui and not remote login, making it mandatory to physically access the server in case of a reboot. Is there any way of accessing the remote desktop of the server without logging in locally ? Also, once a user is logged-in, than on VNC Client it does not asks for username and only asks for the password of the user who is already logged in locally. Any opinions?? There are many articles about running VNC as a permanent background process so that GDM can be utilized for login remotely. However, is this what you really need? You do know about the -Y option to ssh, right? -- Kristian Erik Hermansen Know something about everything and everything about something. Thanks for responding Kris. Let me give it a try and i will get back when it's done. And yeah, I am using putty. I tried loging-in through -Y option but didn't work that way. Regards Smruti -- The greatest pleasure in life is doing what people say you cannot do. ~Walter Bagehot ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22-24, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
Re: [ilugd] Need help to Enable VINO Remotely in Ubuntu
On Jan 30, 2008 12:32 PM, Smruti [EMAIL PROTECTED] wrote: Thanks for responding Kris. Let me give it a try and i will get back when it's done. And yeah, I am using putty. I tried loging-in through -Y option but didn't work that way. I'm not sure putty has this feature. You might need to install OpenSSH and xming... -- Kristian Erik Hermansen Know something about everything and everything about something. ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22-24, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/
[ilugd] French Paramilitary Police Ditch Microsoft For Linux
http://money.cnn.com/news/newsfeeds/articles/djf500/200801300500DOWJONESDJONLINE000225_FORTUNE5.htm http://www.physorg.com/news120930030.html ___ ilugd mailinglist -- ilugd@lists.linux-delhi.org http://frodo.hserus.net/mailman/listinfo/ilugd Next Event: http://freed.in - February 22-24, 2008 Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi http://www.mail-archive.com/ilugd@lists.linux-delhi.org/