Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: SamK on December 03, 2010, 02:32:25 PM

Title: Command Construction for aterm
Post by: SamK on December 03, 2010, 02:32:25 PM
I'm trying to create a .desktop file that opens an aterm and displays some text from a file then remains open at a command prompt once the text is shown.  The aterm manual provides some help, but I'm still left with a couple of problems.

Code: [Select]
aterm -geometry 125x40+0+0 -title WindowTitle -e cat /path/to/text/file.txtopens aterm, does not display the text and immediately closes the aterm window.

Is there a way to keep the window open (an equivalent -hold in xterm)?
What is the construction of the command to display the text from the file?
   
Title: Re: Command Construction for aterm
Post by: tinypoodle on December 03, 2010, 02:40:35 PM
less is more!   ;D

(replace 'cat' by 'less')
Title: Re: Command Construction for aterm
Post by: tinypoodle on December 03, 2010, 02:59:57 PM
Actually on second thought, if I wouldn't have to rely on base only, I would use e3 for that instead of less, saving memory (even with c2fs) and also looking better, IMHO.
Title: Re: Command Construction for aterm
Post by: SamK on December 03, 2010, 03:05:41 PM
What I am after is a method in which aterm remains open at a command prompt once the text is shown to enable input of commands.  Using less the aterm window closes when less is closed.
   
Title: Re: Command Construction for aterm
Post by: tinypoodle on December 03, 2010, 03:44:36 PM
My bad...
Seems I had overlooked the details of the first sentence   :-\
Title: Re: Command Construction for aterm
Post by: ixbrian on December 03, 2010, 06:23:24 PM
Try creating a file that contains this:

Code: [Select]
cat /path/to/text/file
sh

Make the file executable (chmod +x filename), and then call this script from your aterm command. 
Title: Re: Command Construction for aterm
Post by: MikeLockmoore on December 03, 2010, 09:53:05 PM
@ixbrian: Wow, I've been wanting an easy way to do this to add extra program associations to my personal Fluff config file.  Thanks! :D

Example: You want to be able to do hexdumps of any file from Fluff.  Create the following as /home/tc/hexdump.sh:

Code: [Select]
#!/bin/sh
hexdump -C $1 | more
sh

Now the following can be added to the .fluff.conf file:
Code: [Select]
file, Hex, aterm -e /home/tc/hexdump.sh %s &
Now a paging hex dump for any file is only a few clicks away.  ;)
--
Mike L.


Title: Re: Command Construction for aterm
Post by: SamK on December 04, 2010, 10:05:33 AM
Try creating a file that contains this:

Code: [Select]
cat /path/to/text/file
sh

Make the file executable (chmod +x filename), and then call this script from your aterm command. 
Many thanks, that works well.

It has sparked a development of the idea...

Is it possible to create a .desktop file that opens an aterm in the manner now working,  i.e. specifying the executable script but also appending the text file to the Exec line? Something like this
Code: [Select]
Exec=aterm param param param -e /path/to/executable/script.sh /path/to/text/file.txt
The idea being to have the executable script open the text file as %1.

I have tried with this executable script
Code: [Select]
cat %1
echo ; echo
sh
but it reports cannot find %1. 
Title: Re: Command Construction for aterm
Post by: ixbrian on December 04, 2010, 10:25:33 AM
but it reports cannot find %1. 

Try $1 instead of %1.

Brian
Title: Re: Command Construction for aterm
Post by: SamK on December 04, 2010, 11:31:29 AM
but it reports cannot find %1. 

Try $1 instead of %1.

Brian
Once again thanks.  This does exactly what I want.  The two assists have helped produce a most useful result.
   
Title: Re: Command Construction for aterm
Post by: tinypoodle on December 04, 2010, 11:52:58 AM
@ixbrian: Wow, I've been wanting an easy way to do this to add extra program associations to my personal Fluff config file.  Thanks! :D

Example: You want to be able to do hexdumps of any file from Fluff.  Create the following as /home/tc/hexdump.sh:

Code: [Select]
#!/bin/sh
hexdump -C $1 | more
sh

Now the following can be added to the .fluff.conf file:
Code: [Select]
file, Hex, aterm -e /home/tc/hexdump.sh %s &
Now a paging hex dump for any file is only a few clicks away.  ;)
--
Mike L.

More wow!

Inspired by this thread I adapted the idea and implemented a hexdump pager to associate files with in rox filer on my system.
Once that worked I was encouraged, and with the same concept I respectively created a strings viewer which for me is more needed/desirable.    :D

This seems to be one of those concepts which are way too simple for a single mind to come up with, thank you all who contributed.
Title: Re: Command Construction for aterm
Post by: SamK on December 05, 2010, 07:39:24 AM
Here's a link to a topic showing the way in which I applied the answers supplied.  I find it very useful - again many thanks.
http://forum.tinycorelinux.net/index.php?topic=8015.msg43000#msg43000
Title: Re: Command Construction for aterm
Post by: ^thehatsrule^ on December 13, 2010, 11:43:44 PM
If you just want it a one liner, you could do something like
Code: [Select]
aterm -e sh -c "cat file && exec sh"
Title: Re: Command Construction for aterm
Post by: SamK on December 14, 2010, 05:52:48 AM
If you just want it a one liner, you could do something like
Code: [Select]
aterm -e sh -c "cat file && exec sh"
Thanks for the idea.  I have updated  http://forum.tinycorelinux.net/index.php?topic=8015.msg43483#msg43483  as it does away with one of the extensions originally used.

With this refinement I was unable to ensure some distance between the end of the text file and the command prompt.  In the original it was done by multiple echoes, but I could not find a way to make it work in the one-liner.
Title: Re: Command Construction for aterm
Post by: gerald_clark on December 14, 2010, 11:01:12 AM
aterm -e sh -c "cat file && echo -e "\n\n" && exec sh"
Title: Re: Command Construction for aterm
Post by: ^thehatsrule^ on December 15, 2010, 01:35:55 AM
Probably would need something else for the quotes, i.e.
Quote
aterm -e sh -c "cat file && echo -e '\n\n' && exec sh"
or like the earlier post with
Quote
aterm -e sh -c "cat file;echo;echo; exec sh"
Title: Re: Command Construction for aterm
Post by: SamK on December 15, 2010, 01:39:35 AM
aterm -e sh -c "cat file && echo -e "\n\n" && exec sh"
Thanks for the suggestion.  Using double quotes around the newline characters produced nn.  Replacing the double quotes with single quotes gave the desired result.

Code: [Select]
aterm -e sh -c "cat file && echo -e '\n\n' && exec sh"Works as wanted.

This post was made at the same time as a similar reply from ^thehatsrule^
Title: Re: Command Construction for aterm
Post by: SamK on December 15, 2010, 02:20:22 AM
...or like the earlier post with
Quote
aterm -e sh -c "cat file;echo;echo; exec sh"
This works as wanted and have adopted it as I find it easier to read.
http://forum.tinycorelinux.net/index.php?topic=8015.msg43483#msg43483