If you use ssh-agent and have scripts that use commands, such as ssh or scp, that need your ssh key, you may have had the experience of running your script only to discover that you never ran ssh-add to add your key to ssh-agent. So, you type the passphrase once to run the script, and then you have to run ssh-add afterward and type it again to add it to ssh-agent.
To avoid this, add a check to the top of your script to see whether your key is loaded. If not, load it, and avoid having to run ssh-add afterward:
if ! ssh-add -L | grep --silent '/\.ssh/id_.sa'; then ssh-add fi
The -L option of ssh-add shows what keys are added, its output is piped to grep to check to see whether your key is loaded. If it's not, ssh-add is invoked to add your key.
If you want to extract images from a PDF file, you can use the pdfimages program from the poppler package. To extract the images from an entire file, run the command:
pdfimages input.pdf image-root
If you want to extract images from a range of pages, you can use the -f and -l options to specify the first and last pages in the range. To extract the images from pages two to four, use the command:
pdfimages -f 2 -l 4 input.pdf image-root
Images are written to files named image-root-nnn.xxx, where nnn is an image number and xxx is the image type (for example, jpg).
If you have scripts that need to be run as root, you can check for this at the start of the script with:
if [[ $UID -ne 0 ]]; then echo "Must be run as root" exit 1 fi
If you use sudo, you even could restart the script with sudo if it was not run as root:
if [[ $UID -ne 0 ]]; then sudo -p "Restarting with sudo. Password: " sh $0 $* stat=$? exit $stat fi
The sudo command runs the script as sh $0 $*. The sh is included in case the script does not have the execute bit set.
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Dynamic DNS—an Object Lesson in Problem Solving
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Please correct the URL for Salt Stack's web site
2 hours 45 min ago
- Android is Linux -- why no better inter-operation
5 hours 36 sec ago
- Connecting Android device to desktop Linux via USB
5 hours 29 min ago
- Find new cell phone and tablet pc
6 hours 27 min ago
7 hours 56 min ago
- Automatically updating Guest Additions
9 hours 4 min ago
- I like your topic on android
9 hours 51 min ago
- This is the easiest tutorial
16 hours 26 min ago
- Ahh, the Koolaid.
22 hours 5 min ago
- git-annex assistant
1 day 4 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?