Archived

This topic is now archived and is closed to further replies.

Need help with shell script

This topic is 5482 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am currently working on moving some shell script from a UNIX machine to a Linux machine. The Unix machine has the script setup in a terminal that handles messages from the mouse. When the right mouse button is clicked, all text from that point to the end of the line is copied to the prompt. How would I go about setting this up in Linux? On another note, why doesn''t the following command work in Linux(it works under Unix): wc -w testfile | read count

Share on other sites
As for the copy thing, that is probably terminal program specific. I imagine that you just left click, highlight what you want, then right click, and it should be in the prompt (that''s how mine works anyway).

As for the other, what are you trying to do? Is that one line of a shell script? Maybe you could show us what is around it and tell us what it''s supposed to do, and then what it''s doing instead. My guess is that you are trying to assign the number of words to the variable count, but I don''t know what about it is not working, so I can''t help until you give more details.

Share on other sites
I know that it is possible to copy and paste text using the mouse but what I am trying to do is to set-up the mouse to do this automatically. This feature is solely for the convenience of the users. The unix machine loads up these terminals when a certain user account in opened. Do you know where I should look for the commands that are being run?

Yes, that is just one line in a shell script. I would expect it to move the output from wc -w to the variable count but it doesn''t. I dont think anything around it would affect it

Thanks for your help.

Share on other sites
Probably a better way to do it would be to use the backtick operators.

(BASH):

COUNT = wc -w testfile

The  operation will return the output of a command. This shouldn''t create any issues between platforms (assuming the -w switch is available for wc on each platform).

I''m not too sure about the mouse clipboard question, to be honest I don''t use a desktop with Unix/Linux often.

Interim

Share on other sites
Yes, count=wc -w testfile is a better way to accomplish what you want. Sometimes there is whitespace at the beginning of wc output, and I have to remove it with sed ''s/^ *//''.

Interim, you can still copy and paste even in console mode (at least I can under the console in RedHat 9). Highlight it to copy, right click to paste.

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 11
• 21
• 12
• 12
• 11
• Forum Statistics

• Total Topics
631406
• Total Posts
2999897
×