WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Command Construction for aterm  (Read 6749 times)

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Command Construction for aterm
« 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?
   

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Command Construction for aterm
« Reply #1 on: December 03, 2010, 02:40:35 PM »
less is more!   ;D

(replace 'cat' by 'less')
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Command Construction for aterm
« Reply #2 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.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: Command Construction for aterm
« Reply #3 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.
   

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Command Construction for aterm
« Reply #4 on: December 03, 2010, 03:44:36 PM »
My bad...
Seems I had overlooked the details of the first sentence   :-\
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: Command Construction for aterm
« Reply #5 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. 

Offline MikeLockmoore

  • Hero Member
  • *****
  • Posts: 525
  • Good software needn't be big!
Re: Command Construction for aterm
« Reply #6 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.



Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: Command Construction for aterm
« Reply #7 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. 

Offline ixbrian

  • Retired Admins
  • Sr. Member
  • *****
  • Posts: 436
Re: Command Construction for aterm
« Reply #8 on: December 04, 2010, 10:25:33 AM »
but it reports cannot find %1. 

Try $1 instead of %1.

Brian

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: Command Construction for aterm
« Reply #9 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.
   

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Command Construction for aterm
« Reply #10 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.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: Command Construction for aterm
« Reply #11 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

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: Command Construction for aterm
« Reply #12 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"

Offline SamK

  • Hero Member
  • *****
  • Posts: 713
Re: Command Construction for aterm
« Reply #13 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.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Command Construction for aterm
« Reply #14 on: December 14, 2010, 11:01:12 AM »
aterm -e sh -c "cat file && echo -e "\n\n" && exec sh"