Joystiq has your stash of criminally complete GTA IV news!
Posts with tag terminal

Mac 101: Capture sharp screenshots

Earlier this week, we described several ways to create screenshots with your Mac. Using the keyboard shortcuts in the Finder is great, but you may have noticed that the results aren't very sharp. Ivan at creativebits noticed that, too, and figured out how you can correct the problem.

He explains that a basic screenshot creates a JPEG with a resolution of 60 by default. As is often the case, the solution is just a couple of Terminal commands away. Set the default format to png, pdf or tiff for much better results.

If you're not the Terminal type, check out Skitch, which takes simple, great-looking screen captures.

Terminal tip: easy email attachments

If you're looking to automate the sending of emails with attachments quickly and easily (and aren't too concerned with having some glamorous stationery), Terminal is once again your friend. It's possible with Mail.app and AppleScript, but there are a few pitfalls and, for most purposes, a simple shell command will do the trick:

(echo "This is the message body";uuencode Desktop/yourDoc.doc yourDoc.doc)|mail -s "Test attachment" someone@adomain.com

The magical command in this one is uuencode, which is used to encode and decode binary files and can be used on just about any file type. The two arguments in the command above define the name and location of the source file and the name the file should have when it's received. The parenthetical statement at the beginning combines the results of the echo and uuencode commands which are then piped (|) to the mail command. The mail command, having received the body text and attachment, is told to append a subject (-s "Subject") and send it to the address specified. If you wanted to send a longer text file – with line breaks, perhaps – as the body, you could save the text in an external file and replace the echo statement with cat myfile.txt.

By adding a little complexity you could make a shell script that takes arguments, making the automation a little more flexible. But TUAW reader Adam was wondering how to send a photo he'd taken automatically using AppleScript (triggered by a Mail Rule). So here's an AppleScript implementation that doesn't require opening Terminal or dealing with Mail.app scripting:

set msgBody to "This is the body of the message"
set msgSubj to "Message subject"
set mailDest to "someone@adomain.com"
do shell script "(echo '" & msgBody & "'; uuencode /Users/you/Desktop/pictosend.jpg pictosend.jpg) | mail -s '" & msgSubj & "' " & mailDest

Make sure you remove any line breaks from that last line. This obviously requires a predetermined image name, but that could be made a variable as well and used as part of a larger script. We hope this helps, Adam!

Terminal Tip: using whois


Whois or "Who is," is a way to query for contact information (or domain name ownership information) about the person or company in control of a site. If you want to know who runs a website, you don't have to look any further than your Mac and opening a Terminal window.

All you have to do is open Terminal.app (/Applications/Utilities/) and type in "whois" and space followed by a URL. For instance, the following command would give you the whois information for tuaw.com: whois tuaw.com.

You can do this for almost any website; however, some domain names use some form of a hiding service from their registrar that allows them to hide their contact information. Be forewarned that you shouldn't use information like this to stalk people!

Please note that if you have Terminal-itis, or are scared of the Terminal, you can use Apple's Network Utility in Mac OS X to do a whois query. Just open Network Utility.app (in the /Applications/Utilities/) and click the "whois" tab. From there you can enter a URL and do a query, all within a pretty "Aqua-licious" user interface.

Terminal Tips: creating a Spotlight-based gallery

As sexy as Leopard is to me, I'm just as enamored with the powerful UNIX underpinnings of the operating system. I've been toying with a few ways to combine a couple of my favorite command line utilities into something that might prove useful. I won't claim I've achieved a truly practical usage yet, but I thought I'd offer some possibilities. Even for the Terminal-timid, you just might find the potential intriguing enough to slap on some binary camouflage and go all "Code Warrior" for a bit.

I'm going to elaborate on some image processing techniques using results from Spotlight searches. In order to make use of the examples without modification, you'll need to have a collection of images containing IPTC keywords (or very descriptive filenames). With a little modification, the searches can be expanded to other criteria. But if you can't run a spotlight search and find at least 8 jpegs with one keyword, you'll have to accept this as a proof of concept. But, that being said, let's get started.

Continue reading Terminal Tips: creating a Spotlight-based gallery

DTerm: give your Mac a little shell love

DTerm screenshotDTerm is a utility just released by Decimus Software Inc. It's a Leopard-only app that provides a hotkey-triggered HUD which allows shell commands to be run from anywhere in OS X. In case you're wondering why, just imagine what less window switching and screen clutter could mean for productivity on jobs that require both Finder and Terminal. Yes, you can do a lot with Quicksilver, but DTerm provides bash name completion with a dropdown, context sensitivity to your current path and full output with clipboard features. You can also type ⌘-↩ in the HUD to run the command in the Terminal, which will open up to your current path.

DTerm is all about reducing effort, really. The process of running a command in the current directory is reduced to just a few keystrokes and there's no need to grab the mouse or switch to another application. Better Path Finder integration would be nice, but the developers tell me that it's Path Finder's own use of the Accessibility system that prevents that right now.

DTerm requires Leopard and has a free demo (up to 50 commands) after which the program costs $20. Visit the DTerm page for the download and more info, including a speedy video that will satisfy your secret bash-voyeurism fetish and won't waste much of your time.

Using Data Detectors in Leopard's iChat

Data Detectors in iChatI'm always, well, tickled by the things that can happen when you use Terminal commands that begin with "defaults write" -- thus changing the preferences for applications, the Finder, and more, often in ways that you can't accomplish via GUI pref settings. I also get a certain warmness from Leopard's Data Detectors, but I have to confess I rarely use them. It's fun to watch the things that Mail can pick up on, and I've often tested to see what exactly iCal will make of it, but I guess some people just get better emails than I do. Strangely, I do get dates and info via instant messaging on a more regular basis.

You can enable Data Detectors in iChat with one simple command in Terminal:

defaults write com.apple.iChat EnableDataDetectors 1

You can disable it using the same command, but change the '1' to a '0.' Now you get the fun job of calling your closest Mac-using relative and explaining Terminal so they can use a feature that Apple hid from public view for what I can only assume were valid reasons. I hope your aunt has her screen-sharing figured out.

[via Mac OS X Hints]

A (slightly) simpler command-line Spotlight search

Erica mentioned mdfind a little while ago. It's not a brand new tool, but there hasn't been a great deal of discussion surrounding it. For shell scripters and Terminal junkies, it's a goldmine of search goodness that can make you never want to key out find . -name "letsgogetcoffeewhilewewait.rb" or even locate didcronupdatethedb.yet again.

There are two mdfind options mentioned at Mac OS X Hints that are worth a mention, one found only in the man page, and one found only in the usage info. The former being "-interpret", which allows the advanced Spotlight query syntax to be used on the command line as if typed into the Spotlight window, turning mdfind "kMDItemContentType == 'public.jpeg'" into mdfind -interpret "kind:jpeg". Its opposing force would be "-literal", which forces a literal interpretation of the query string. Any qualified Spotlight query should be usable with "-interpret", so go ahead with mdfind -interpret "kind:image flash:1 modified:<=1/1/08 ex-girlfriend" to find those late-night pictures of last year's special someone. That would take a lot of metadata work to pull off without "-interpret".

The second option mentioned isn't in the man page, but you'll see it in the usage info if you run mdfind with no parameters. It's the "-s" option that loads saved searches. It will look in ~/Library/Saved Searches unless a path is specified. So you can save a search in Spotlight called "PDFs from yesterday" and run mdfind -s "PDFs from yesterday" to launch the same search at the command line. See, I had to throw a "normal" search in there to keep you on your toes.

Terminal jockeys can mix these up with a few pipes, stir in some perl and sprinkle in a little awk to get some really great Spotlight soufflé. Of course, if you don't like the command line and you're still reading this, you're a downright hardy trooper and I commend you. Go have a cup of coffee, you deserve it.

[via Mac OS X Hints]

Secure your Mac: Crouching user, hidden folder

Here are a few very simple steps you can take to enhance your Mac's security - not exactly the U.S. Government's Advanced Encryption Standard (AES) algorithm, but enough to thwart many end-users.

Create a guest user account

Occasionally, someone will ask me, "May I quickly check my email on your computer? Just real quick..." (often these are Windows users who need an excuse to play with the MacBook Pro). "Sure," I say, but before I hand over the reigns, I switch to my guest user account. Here's how you can create one.
  1. Click System Preferences, then Accounts
  2. Click the small "+" icon at the bottom of the window
  3. In the sheet that appears, set up your guest account. I got fancy and named mine "guest," with a password of "guestpw," but you can choose whatever you like.
  4. De-select "Allow user to administer this computer."
Now, when someone "borrows" my computer to check their mail, they see an empty home folder, blank email client...the works. Even the rude ones who try to quickly peek won't find anything.

Create a hidden folder


Mac OS X automatically hides a folder that begins with a period. We can use this to our advantage and create a secret folder. However, it's not as easy as creating a folder in the Finder and naming it ".MyPrivateStuff." But it's not difficult, either.
  1. Open Terminal. By default, you're in your Home directory
  2. Create a new folder with a "." as the first character using the "mkdir" command, like this: mkdir .MyPrivateStuff
  3. Hit return. You're done!
So how do you access that folder from the Finder? Navigate to your Home folder (open a new window and click the little house in the left sidebar). Now, select "Go to folder..." from the menu bar. Enter the name of the folder you created, including the period (in my case, .MyPrivateStuff). Presto! Your hidden folder appears in the Finder window. Now populate it with your "secret" stuff (financial in nature, of course).

One caveat: The Finder "remembers" the last folder you visited with this method, so be sure to "Go to..." a benign folder before you walk away.

Combine the two tips


If you really want to get fancy, combine the two tips: Create a new user account that does nothing but store your secret folder(s).

Again, this isn't military-grade security, but simple techniques that you can use as an extra layer of protection for some of your stuff. Good luck.

Apple IIc as a serial terminal to a Mac Mini

Hot on the heels of the Apple IIe-into-a-Linux-terminal tutorial we posted the other day, here's another mix of retro and modern-- Byte Cellar has hooked up an old Apple IIc (or //c if you spin that way) to work as a terminal to a Mac Mini. It's pretty neat-- sounds like they frankensteined the IIc's serial port to a USB connection, put ModemMGR on the IIc (which is three whole floppies), and now are using the old "luggable" as an IRC client, which is a perfect use for it, and, as Blake says, makes it feel "great to twiddle the //c's keys in a meaningful way every workday."

There's also a photo gallery of the whole setup, which shows the spliced cable, as well as the whole setup in all its glory (yeah the XP box mars it a bit, but no one's perfect). Very cool. Makes me wish I still had one of those old clunky Apple IIs, if only to run IRC as it's mean to be run-- with nothing but green text on a black screen.

[via Digg]

Mac 101: Reset your Mac OS X password

We've all done this.* It's time to install something or run Software Update, but first we've got to enter our password. What was it again? Oops.

You can reset your password with the CD (or DVD) that came with your Mac, but if you don't have it, try this tip from Hackszine. Restart your machine while holding down the Command Key (or "Apple Key") and the "S" key. This will start your Mac up in "Single User Mode."

Now it's command line time.** Don't worry, it's just three lines:
  • #sh /etc/rc
  • #passwd yourusername
  • #reboot
Ta-dah! You may return to what you were originally doing. Just write that new password down first.

*Well, not us, but, you know...our "friend."

[Via Lifehacker]

**Update: this post has raised some understandable security concerns among our readers. Our own Mike Rose had this to say:

"Not this caveat, from a commenter at Hackazine: if you have a FileVault-protected home directory, you cannot use this hack. Changing your password from the command line will render your home directory completely inaccessible, probably permanently."

SSH shell for iPhone

We know what you've been thinking. "Gee, I wish I could SSH into my Mac with my iPhone." Well, now you can.

WebShell is simple enough to install (just two commands in Terminal) and configure. Once it's all set up, point your iPhone to http://localhost:8022 in Safari and you're good to go!

The folks who are working on this are asking for your input. Send them your screenshots and experiences so they can make it even better. WebShell is free.

ChangeShortName updated to 1.3

A few weeks ago, in discussing some things not to do with your Mac, one of our commenters asked why changing the shortname (the abbreviated version of your username you see in Terminal, as the name of your 'home folder' or in Get Info windows) is such a nasty bit of business on Mac OS X. Shouldn't it be easy as pie, on the 'computer for the rest of us,' to make this quick and trivial modification? Well... it isn't. In part due to Mac OS X's UNIX heritage and in part due to NetInfo (a chunk of the NeXT operating system that hopefully won't be around forever), the shortname gets tucked away in a lot of tricky wee places, and getting them all updated manually is a path to disaster.

Fortunately, as Scott mentioned way back in ought-five, there's a somewhat easier way: James Bucanek & Dan Frakes' handy-dandy and free ChangeShortName utility. This tool, now updated to version 1.3 and featuring an all-new Cocoa interface, will give timid people the strength to do what must be done and change your shortname for you, as an absolute last resort. Seriously, you are not allowed to use this program without reading the included (and well-written) manual, and you should heed the FAQ that asks "Q: Should I be scared of ChangeShortName? A: YES."

The authors suggest learning to live with your hella lame shortname, or creating a new account and migrating your data instead of changing the name; if something goes wrong in the process, your efforts at account aesthetics might render your machine unusable. You've been warned!

Thanks Dan & James

Terminal Tip: Interactive Command-line File Encryption

In OS X, you can always toss a file onto the command line instead of laboriously typing out a complete path name because Terminal supports drag and drop. Over at Murphymac, Murphy has posted a video showing you how to create a shell script using DES3 encryption to protect your files. It takes advantage of this drag and drop support so you can basically run the script and drop the file you want to encrypt. Even if you're not all that interested in encrypting your files, this videocast shows how to think about creating shell scripts with a particularly interactive OS X flare flair.

Terminal Tip: Finding by Time

Have you ever lost track of a file that you were just working on? Or were you ever curious about which files an installer has just added or modified? The command line find command offers a simple way to track down any files created or updated within the last few minutes. Its amin and cmin flags tells find to locate files that changed with a certain number of minutes, e.g. to search within 10 minutes: find / -cmin -10 or find /Users/ericasadun/ -amin -3. The - before the time says to find within the time period (with, say, the last three minutes) rather than to look for exact time matches (at 3 minutes ago exactly).

Terminal Tip: Accessing built-in calendars

On Sunday, I posted about the built-in calendars found in /usr/share/calendar. These calendars include listings of events from around the world and for religions, e.g. calendar.history and calendar.christian. Today, I thought I'd share some ways to access those calendars from the command line.

On pretty much any version of Mac OS X, you can use the built-in calendar command to list the events of the day. The -f flag allows you to select which calendar you want to access. The calendar.world file references all the other English-language calendars.

% calendar -f /usr/share/calendar/calendar.world
Apr 13 Thomas Jefferson born, 1743
Apr 12 Confederate troops fire first shots of Civil War at Ft Sumter, 1861
Apr 12 Space Shuttle Columbia launched, 1981
Apr 12 Yuri Gagarin becomes the first man in space, 1961
Apr 13 Laotian New Year (3 days) in Laos
Apr 13 National Day in Chad
Apr 13 Songkron Day in Thailand
and so forth...
%

You can embed this command into your startup files like ~/.bashrc so the events of the day display whenever you open a new shell. Unfortunately, the calendar command does not seem to work properly on my Intel-based Mac Mini; Mike reports that it works just fine on his MacBook Pro. If your Intel Mac is balking at the calendar command, you can use grep as a workaround: grep `date +%m/%d` /usr/share/calendar/calendar.*

Next Page >

TUAW Features


Mac 101 ask-tuaw
Mac News
WWDC (250)
.Mac (57)
Accessories (635)
Airport (74)
Analysis / Opinion (1328)
Apple (1636)
Apple Corporate (554)
Apple Financial (187)
Apple History (45)
Apple Professional (53)
Apple TV (160)
Audio (446)
Bad Apple (118)
Beta Beat (149)
Blogging (84)
Bluetooth (16)
Bugs/Recalls (56)
Cult of Mac (869)
Deals (214)
Desktops (115)
Developer (251)
Education (98)
eMac (10)
Enterprise (136)
Features (396)
Freeware (381)
Gaming (360)
Graphic Design (31)
Hardware (1281)
Holidays (37)
Humor (576)
iBook (65)
iLife (234)
iMac (184)
Internet (325)
Internet Tools (1309)
iTS (967)
iTunes (796)
iWork (21)
Leopard (366)
Mac mini (112)
Mac Pro (53)
MacBook (202)
MacBook Air (79)
Macbook Pro (220)
MobileMe (16)
Multimedia (439)
Odds and ends (1437)
Open Source (277)
OS (910)
Peripherals (208)
Podcasting (182)
Podcasts (89)
Portables (197)
PowerBook (135)
PowerMac G5 (50)
Retail (577)
Retro Mac (48)
Rig of the Week (42)
Rumors (629)
Software (4303)
Software Update (406)
Steve Jobs (252)
Stocking Stuffers (50)
Surveys and Polls (97)
Switchers (111)
The Woz (34)
TUAW Business (235)
Universal Binary (281)
UNIX / BSD (61)
Video (902)
Weekend Review (81)
WIN Business (47)
Wireless (83)
Xserve (39)
iPhone/iPod News
iPhone (1485)
iPod Family (2024)
App Store (16)
SDK (14)
Mac Events
One More Thing (27)
Liveblog (1)
Other Events (226)
Macworld (489)
Mac Learning
AppleScript (2)
Ask TUAW (101)
Blogs (85)
Books (26)
Books and Blogs (62)
Cool tools (443)
Hacks (459)
How-tos (482)
Interviews (43)
Mods (185)
Productivity (586)
Reviews (107)
Security (153)
Terminal Tips (58)
Tips and tricks (563)
Troubleshooting (166)
TUAW Features
iPhone 101 (26)
TUAW Labs (3)
Blast From the Past (17)
TUAW Tips (141)
Flickr Find (34)
Found Footage (80)
Mac 101 (88)
TUAW Interview (31)
Widget Watch (198)
The Daily Best (1)
TUAW Faceoff (4)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

The Unofficial Apple Weblog (TUAW) bloggers (30 days)

#BloggerPostsCmts
1Cory Bohon862
2Robert Palmer6046
3Steven Sande5623
4Scott McNulty370
5Dave Caolo370
6Mat Lu348
7Erica Sadun282
8Mike Schramm212
9Brett Terpstra210
10Michael Rose1334
11Christina Warren1242
12Joshua Ellis54
13Lisa Hoover26
14Jason Clarke11
15Chris Ullrich12

Featured Galleries

Macworld 2008 Keynote
Macworld 2008 Build-up
Apple Vanity Plates
DiscPainter
Macworld Expo 2007 show floor
The Macworld Faithful in Line
iPhone First Look
AT&T 3G Coverage Map
MobileMe Guided Tour UI Changes

 

    Most Commented On (7 days)

    Recent Comments

    More Apple Analysis

    More from AOL Money and Finance

    Weblogs, Inc. Network

    Other Weblogs Inc. Network blogs you might be interested in: