![]() |
Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Can anyone tell me how to create a new text file in xterm? I'm trying to follow the directions on the how to use xterm wiki about setting up a profile. Unfortunately, creating a new text file within xterm is not something I've learned to do yet.
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
vi's a text editor that you can use inside xterm
vi .profile may do it. bit odd to learn however. |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
I normally use Touch.
Quote:
Code:
Code:
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
The tone of your reply makes me think maybe I'm doing something wrong. Which is quite possible because I'm following a fairly convoluted path to solving my problem.
Problem: I'm trying to teach myself Python. The Python tutorial I'm using at byteofpyton.org says, in order to execute a python program that I write from any directory within the CLI, I need to edit the "PATH environment variable". That is, if I want to run my Python programs without first cd'ing to the dir in which the programs exist, I need to set up the "PATH environment variable". From this thread I got the impression that, in order to edit this "PATH environment variable" that I need to create a .profile file. For this, I was following the instructions specified on the xterm wiki. Am I totally barking up the wrong tree here? |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Looking at that site, I'll tell you the quick way to do this (setting the path).
echo export ENV=$HOME/.shrc >> ~/.profile echo PATH=$PATH:PUTYOURDIRECTORYHERE >> ~/.shrc Replace PUTYOURDIRECTORYHERE with the directory you would like to run the program from. remember you cannot run from mmc. |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Essentially Echo does have the ability to write to files (if you use >>) and the file has to be on the right side. The ~ means to create a file in your home directory and the .profile means that it will create that file (.profile) but it will be hidden from your view (in programs like the built in editor and file manager). If you run "ls -a" without the quotes then you can see files in a directory if they have a dot in front or not.
You cannot run programs from the SD cards because of the file system used on them. Also, if you want to make changes to a file (as opposed to dumping text into them) then you will need a text editor to do it. Vi and nano are possibilities. However, if you run the echo commands above properly the first time then an editor isn't needed... just make sure to run the right commands. |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
it may, for instance, be possible to avoid automated detection at a toll booth by passing through it at a very high speed -- but you wouldn't expect someone unfamiliar with driving to accomplish this task without a high liklihood of catastrophic failure... |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
In order to execute a program (any program, not just python programs) from the CLI, you have to write the full path to that program. You can write an absolute path (which starts at the root directory named "/"), or a relative path (which starts at the "current directory"). For example, if you have written a program named "mytest.py", and placed that program in the folder /home/user/myscripts/, then in order to execute that program you have to write: Code:
/home/user/myscripts/mytest.py Code:
./mytest.py If you do not specify any path before the program name, i.e: if you simply write: mytest.py in the CLI, and press Return, then the PATH variable come into action. This variable holds a list of directories, separated by colons. The CLI will search the program you want to run in this list, one directory at turn. When the program is found, it is run. If the list is exhausted and the program is not found, you obtain the message: Code:
-sh: mytest.py: not found Code:
echo $PATH You can alter the PATH variable, by assigning it a new value, and "exporting" it. For example: Code:
export PATH=/home/user/myscripts No panic. The changes to the PATH variable are local. They dissapear if you end the CLI session, so close the xterm and open a new instance. That is, you have your PATH restored, everything works again. If you want to *add* a new directory to your PATH variable, as opposed to *replace* it with a new directory, you can use the following syntax: Code:
export PATH=$PATH:/home/user/myscripts Code:
export PATH=/usr/bin:/bin:/home/user/myscripts So this is the whole story about the PATH variable? Well, it is if you dont mind to write the PATH assignation each time you open xterm. Remember that changes to the PATH variable are lost when xterm is closed. If you want to make these changes more permanent, you will be glad to know that, if you write a shell script named .profile and put it in your $HOME, it will be run each time an xterm is open (to be precise, when a shell session is started, even if you start it from ssh). So you can write a .profile which assigns your PATH variable as you like, and have this value assigned automatically in each session. Creating files from command line Now for your question. To write .profile (or any other file), you should use an editor. vi is an editor which comes with the OS, but it is difficult to use. However, for very short files, you can write them from the command line, using the echo command, or the cat command. I prefer the later: Code:
cat >> $HOME/.profile The cat command, used as above, appends all text you type (up to the Ctrl-D, which means "end of file") to the file you specify after the ">>" You should type carefully, because you cannot edit a line after you press Return. Even before pressing Return, the editing capabilities are very restricted. You only can delete chars (using backspace) and write them again, but you cannot move the cursor in the line. However, for short texts, or for text which are "copy&pasted", cat can be a quick way of creating file contents. |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
And thanks to everyone for the info, especially jldiaz who has proven, yet again, to be very patient and willing to help a cluelees noob such as I. It was very clear and helpful. |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Good posting by jldiaz.
To start editing a file you will also need to use a text editor of some kind. 'vi' comes pre-installed. I myself only know the most basic commands so I use it only for simple stuff (like updating the already mentioned configuration files). Still, it's a powerful editor and can be used for writing e.g. python programs, if you want to. Here's a guide to using vi: (there are others, easy to find with google): http://www.cs.rit.edu/~cslab/vi.html UPDATE: I forgot to mention that the 'esc' key (essential with vi) is the physical button with that curved little arrow. |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Two questions:
Can someone post the contents of .profile please? Do any/many applications add to the path on installation? |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
I think it might be worth mentioning here that, unless you've installed a bash interpreter on your tablet, you normally end up running busybox--which doesn't run .profile in your home directory. If you create one and attempt to use it, it will be ignored.
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
I was trying to add a folder called Scripts so that I could keep all home writtem scripts in one location. I used > instead of >> duh! |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
if you are unsure about using the command line maybe a filemanager like mc can help you. You can copy, edit, extract files in a very simple way. Just 'apt-get install mc' if you are using debian, ubuntu or your nit to install mc. Then you can start it with mc or mcedit (just the editor).
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Interesting, it's been my understanding that busybox on the tablets ignored .profile ...I'll need to play with that later and see for myself again!
If you have limited knowledge, I appear to have limited experience with the topic. :P Anyway.. as for your problem right now.. did you have SSH installed as a service? You could try maybe logging in as root user to go in and rename the .profile so that it doesn't get run. (cd /home/user; mv .profile .profile.bak) |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Quote:
|
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Just to add some clarification. xTerm still appears to work as far as I have seen. Commands such as ls, cd etc work. Since I know I only have one path statement in .profile it does support the comment that .profile is ignored in xTerm (which I presume runs busybox).
BUT I do get an error when I start xTerm which comes from the path statement which suggests xTerm IS reading .profile! I think, in any case, I do need to correct .profile and I do need to add my folder called Scripts to the path to enable me to run commands from the osso-statusbar. The great post earlier in this thread explains how to create and add to .profile and I think this will be enough to get me back to where I was. I just need to know WHAT was in .profile before I overwrote it. BTW, I am not using SSH. I was doing everything on the N810 in xTerm. Also I don't appear to need to gain root to edit, create or (probably) delete .profile mc sound helpful if it allows editing on the tablet. I presume I could find it in App Manager as well as pull it from the command line? Thanks for all the input, I din't mean to start an argument!!! |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
The busybox shell uses the .profile if one exists, but it doesn't come with one. So to answer Derek, there's no original .profile we could post for you..
However, it's mostly used to add to the PATH. You have your scripts in $HOME/MyDocs/Scripts/, don't you? So you would maybe want something like PATH=$PATH:/home/user/Mydocs/Scripts For myself, I have manually installed some non-busybox versions of some commands in /usr/local/bin which I want to override the busybox ones (those in /usr/bin), so I put /usr/local/bin first in the path: PATH=/usr/local/bin:$PATH And I also like to see all directories and files, even those starting with a dot, when I use the 'ls' command. So I have: alias ls='ls -AC' (Note that in general environment variables must be 'exported', e.g. VARIABLE="value" export VARIABLE but PATH is already exported so it's not needed.) |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
Wow, you found me. I thought I had bothered you enough and came over here after a search on .profile.
I think it makes sense now. .profile did not exist but the line I put in when creating it was 'corrupted' with a 'not found' string. This is what yields the error message and why everything still works. I just need to get the syntax right to point to Scripts. I like your alias. Can this be inserted as written in .profile? I'll return to the other thread if there are more GVM backup issues (not that you have to answer). Thanks again! |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
dfinch
just use rm .proffile then re-enter the correct line. rick |
Re: Ultimate linux CLI noob question: "How to create a plain text file within xterm?"
|
All times are GMT. The time now is 17:40. |
vBulletin® Version 3.8.8