LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2008, 03:02 PM   #1
internetSurfer
Member
 
Registered: Jan 2008
Location: w3c
Distribution: Slackware 12 Zenwalk 5.2
Posts: 71

Rep: Reputation: 16
Bash Script ? How to delete directory then run program.


I am trying to create a script that checks
for a dir or file and if present have it
deleted then run a program.

Code:
#!/bin/sh 
# Delete directory.

if [ -d directory ]; then

  exec rm -r directory
  exec "How to start the program?"

fi

Last edited by internetSurfer; 01-18-2008 at 03:14 PM. Reason: title update
 
Old 01-15-2008, 03:23 PM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 71
Why do you need exec?
To run an executable (start a program), just give a full path to it.

Code:
#!/bin/bash

if [ -d directory ]; then
  rm -r directory
  /usr/bin/emacs
fi
 
Old 01-16-2008, 11:52 AM   #3
internetSurfer
Member
 
Registered: Jan 2008
Location: w3c
Distribution: Slackware 12 Zenwalk 5.2
Posts: 71

Original Poster
Rep: Reputation: 16
Thanks it worked.

-------------------------
For reference:

Advanced Bash-Scripting Guide
http://www.linuxtopia.org/online_boo...ripting_guide/

A beginners guide to Linux.
http://linuxreviews.org/beginner/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM
[bash] having trouble debugging this bash script. jons Programming 4 02-08-2007 06:51 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration