LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-25-2014, 05:23 AM   #1
Jykke
Member
 
Registered: Sep 2005
Posts: 201

Rep: Reputation: 19
Problem with executing a hell command from tcl


I ain't a tcl crack but I am trying to improve the situation. I want to execute a linux shell command:
exec grep Title [lindex $argv 0] | awk '{print $2}' > tmp.txt
so far so good, but I get a message:
Error in startup script: can't read "2": no such variable
while executing
"exec grep Title [lindex $argv 0] | awk '{print $2}' > tmp.txt"
(file "/home/q275880/tcl/quick_plot.tcl" line 7)

well yes, I want to pass the $2 in such a form to linux shell but somehow tcl
takes it as its own variable. I already tried putting the command in quotes and
stuff, unfortunately with little success.

Any ideas?
 
Old 04-25-2014, 09:56 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
WORKING WITH QUOTED ARGUMENTS:

Quote:
When translating a command from a Unix shell invocation, care should be taken over the fact that single quote characters have no special significance to Tcl. Thus:

Code:
awk '{sum += $1} END {print sum}' numbers.list
would be translated into something like:
Code:
exec awk {{sum += $1} END {print sum}} numbers.list
So I think you want
Code:
exec grep Title [lindex $argv 0] | awk {{print $2}} > tmp.txt
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem while executing an .tcl code on ns 2.35 mezyana Linux - Software 5 04-22-2014 06:50 AM
Error while executing tcl... Ganesh3691 Linux - Wireless Networking 1 04-20-2014 12:39 PM
error while executing blackholeAODV tcl k_kimo Linux - Wireless Networking 5 06-27-2013 03:07 AM
invalid command type "llType" error occuring when executing a tcl script in ns2.34 madhu.bm Linux - Software 1 05-04-2012 05:30 AM
TCL executing commands riotxix Programming 1 12-30-2006 12:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration