Using PICO

software development

#1

Hello,
I installed awstats per the instructions here: http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=3rdparty&Number=13050&page=&view=&sb=&o=&vc=1#Post13050
but when I try to install a cron job, pico ends up wrapping the command on 2 lines, which causes the cron job to not run.

Any suggestions as to how to keep it on one line?

Thanks,
Jennifer


#2

I was having a bit of an issue with this when trying to write some shell scripts. One way around it is to write the file on your own computer, using somethign like note pad, save the flie and up-load.

There may be a way to do this with pico though telnet or ssh, but I don’t know about that.

-Matttail


#3

Thanks, but I’m still a bit stuck. How does the -w fit in to these instructions: http://discussion.dreamhost.com/showthreaded.pl?Cat=&Board=3rdparty&Number=13050&page=&view=&sb=&o=&vc=1#Post13050?

I’ve tried various ways, but I can’t get it to work together. I need the -w to be for instructions, not a file.

Sorry - I’m a total newb at this.


#4

what’s happening is when you edit your cron file the command below is getting split into two lines, when for a cron job, they need to be just one line.

0 3 * * * perl /home/yourusername/awstats/tools/awstats_buildstaticpages.pl -config=example.com -update -awstatsprog=/home/yourusername/awstats/awstats.pl -dir=/home/yourusername/example.com/statistics/

if you just copy and paste the above into your editor, which you’ve set to pico, (after typing crontab -e) then it will insert line breaks, which you don’t want. you can remove the line breaks by going to the first character of each new line and typing the delete key to bring it up to the line above.

or if that’s not making sense or not working, try this, making sure to copy and paste precisely what’s below:

echo “0 3 * * * perl /home/yourusername/awstats/tools/awstats_buildstaticpages.pl -config=example.com -update -awstatsprog=/home/yourusername/awstats/awstats.pl -dir=/home/yourusername/example.com/statistics/” > ~/awstats_cron.txt

  • then do crontab -e (to get into the editor)
  • type ctrl-r to read in a file to pico, and enter ~/awstats_cron.txt
  • and then type ctrl-x to save.

this should work.


#5

“you can remove the line breaks by going to the first character of each new line and typing the delete key to bring it up to the line above.”

I’ve done that, then added a new space - not a carriage return - and it still wraps. Are you saying to remove the spaces from the entire command completely?

"making sure to copy and paste precisely what’s below:"
What exactly am I pasting it into? I tried:
export EDITOR=pico
then pasting what I’d just copied, nothing happened. Then I tried typing export EDITOR=pico, then crontab -e, then pasting, but nothing.
Are you saying to create a new file, awstats_cron.txt, with the “echo…” line?
When I said I was a total newb at this, I meant TOTAL newb. :slight_smile:


#6

This did the trick! The cron ran last night.

Thank you!!!


#7

Vim is your friend! I highly recommend learning. It’s by far the best command line text editor you could ever use, once you get to know it’s key commands. It’s quite simple really. Once you get a hang of it, you’ll wonder why you’ve waited so long to learn it.

I know this from experience. I used PICO for 2 years when I first started out on Linux/Unix based systems. Eventually I gave in and decided to learn vi (mostly cause PICO wasn’t on Unix/Linux by default–and I was on a number of *nix systems). Needless to say, I’ve been using vi/vim ever since (8 years now).


#8

Emacs requires GUI. So does UltraEdit, BBEdit, etc…

I’m talking purely command line. I did state “on unix” based systems (or through telnet/ssh/etc), vi(m)'s the best editor out there. :wink:


#9

Emacs was actually first command-line before the gui version was released. It works on both. I used emacs for a long time when I first started programming in UNIX in college and only learned vi when I had to do unix admin stuff on a lot of different systems. Vi is everywhere and emacs (and everything else) is not. Plus, emacs is not ideal for editing unix system files for a couple of reasons.

A good alternative to pico for basic editing like crontabs is nano. That’s actually what should be set as the editor by default on DH servers. Nano is very similar to pico (it was originally a clone of pico), but it doesn’t do the annoying linewrap thing pico does. I use nano for a lot of things myself.

I could go on about text editors for days…

  • Dallas
  • DreamHost Head Honcho/Founder

#10

[quote]but it doesn’t do the annoying linewrap thing pico does. I use nano for a
lot of things myself.

[/quote]

Another nice thing about nano is that it can tell you what line you’re on. If I recall, pico doesn’t have that option, making it largely useless for coding purposes.

I prefer BBEdit for 99% of my extended coding time, though I’ve been using UltraEdit on a Windows box off and on (for some reason, I’ve been very unimpressed with most of the Windows-based editors - can’t quite figure out why, though).

I use nano if I need to tweak something on the server and don’t want to launch a full-fledged editor. For what it is, it works very well.

[quote]I could go on about text editors for days…

[/quote]

Most of us could, I think. :>

  • Jeff @ DreamHost
  • DH Discussion Forum Admin

#11

To be fair, I’m pretty sure that nano wraps lines by default just like pico does. I did a quick test, and both pico do this when used as an editor for “crontab -e”. Nano is a pico clone, though with some enhancements/ improvements. Either can be called with “-w” to avoid wrapping lines. If you want to be sure not to wrap lines, set $VISUAL to:

“pico -w"
or
"pico -tw”
(to save the changed file without prompting for the filename - this is great for crontabs, but doesn’t always work properly for other applications that follow $VISUAL / $EDITOR - I believe this is why DH did not set this by default)

So something like:
export VISUAL=“pico -wt”
(bash / ksh / zsh, in your .profile / .bash_profile or whatever; to work for real sh too, declare and export the variable separately)

setenv VISUAL “pico -wt”
(csh / tcsh, in .cshrc or .tcshrc)

While $EDITOR will work too, $VISUAL is the preferred environment variable to use; historically, $EDITOR is your line editor (e.g., ed / ex) and $VISUAL is your full screen editor (e.g., vi / emacs).

Side note - vim also has some funkiness with crontab -e, due to the way it handles backup files[1]. The workaround is to not keep a backup for certain filenames or for files in a certain directory. This results in the maddening “crontab: no changes made to crontab” error, after saving the file in vim.

I think something like this will work (in your .vimrc or in a global Vim config file):

au VimEnter crontab* set nobackup nowritebackup

I always just use nvi instead.

[1] http://lists.apple.com/archives/unix-porting/2003/Mar/msg00038.html


#12

SciTE all the way for Windows. It’s smaller and faster than Notepad, with Syntax Highlighting! I’d highly recommend giving it a shot. I’ve fully replace Notepad for SciTE on all my winbloze boxes.

Most likely does. The difference, however, is that Pico will actually hardwrap the lines. Meaning, once you save, Pico, by default, will put a hard \n at the location the line wrapped. This is a very bad “feature”.