LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-11-2004, 02:54 PM   #1
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
How to create a ".bat" equivalent file


I just need to create a little script that does the below when I execute it.

Code:
rm -f /home/ken/.etwolf/etmain/profiles/CheewagaCheewaga/profile.pid
rm -f /home/ken/.etwolf/etpro/profiles/CheewagaCheewaga/profile.pid

et
How would I go about creating this?

**whoops, this should've went in the Linux NEWBIE section, not the software section.
 
Old 11-11-2004, 03:05 PM   #2
zhangmaike
Member
 
Registered: Oct 2004
Distribution: Slackware
Posts: 376

Rep: Reputation: 31
Code:
#!/bin/bash

rm -f /home/ken/.etwolf/etmain/profiles/CheewagaCheewaga/profile.pid
rm -f /home/ken/.etwolf/etpro/profiles/CheewagaCheewaga/profile.pid

et
Save that to a file, then make it executable with:
"chmod +x insert-filename-here"
 
Old 11-11-2004, 03:18 PM   #3
huibert.alblas
Member
 
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226

Rep: Reputation: 30
Creating shel scripts

To create a shell script, (a batch file in the linux world)
open your favorite editor and edit new file.
The name does not realy matter in linux but "cleanup.sh" would be a nice one.
Note that the extension .sh is not mandatory in linux,
as opposed to windows where batchfiles must have a .bat extension.

in your editor type:
#!/bin/bash
rm -f /home/ken/.etwolf/etmain/profiles/CheewagaCheewaga/profile.pid
rm -f /home/ken/.etwolf/etpro/profiles/CheewagaCheewaga/profile.pid


And save this 3 line file.

The first line indicates which shell enviroment should execute the script.
Normaly /bin/bash is what you want, but you may also write in Perl or any even php for that matter.
(But if you use php you should point to the php command line interpreter)

Now to make the scrip executable do a:

chmod 0700 cleanup.sh

This will set the owner_user read / write / execute permissions on this file to true, all other users may not
read write or execute this script.

If your script lies in your current directory you can do:
./cleanup.sh

to start it.
(normaly command/scripts from the current directory will not run for security reasons, ask if you want to know why....)


The other method would be to mv the file to /urs/local/bin (as root) so it will be in your search path.


Hope this helps.

read the bash scripting howto for more info:

http://www.tldp.org/LDP/abs/html/
 
Old 11-11-2004, 03:23 PM   #4
dishawjp
Member
 
Registered: Dec 2003
Location: Central New York
Distribution: RH/Fedora/SUSE
Posts: 64

Rep: Reputation: 15
Zhangmaike is perfectly correct in what he says.

For consistancy, you might want to give the file a .sh (as in shell) extension. Not that bash cares like MS operating systems would, but it is a convention.

The other thing I would mention is that unless you write the file to a pathed directory, you will have to either specify the full path of the file or be in the file's directory and call it as sh ./filename.sh.

I keep a user pathed ~/bin directory for my shell and perl scripts. You can edit your .bash_profile file to add that directory to your path if you choose.

Sorry if these were things you were already aware of.

Jim Dishaw

(edit)

Looks like I was posting at the same time as another poster. Once I submitted my post I saw his. I'm not just repeating his post.

Last edited by dishawjp; 11-11-2004 at 03:25 PM.
 
Old 11-11-2004, 03:41 PM   #5
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Original Poster
Rep: Reputation: 45
Thanks for all your help!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
vsftpd & "553 could not create file" steffentchr Linux - Server 8 06-28-2012 01:52 PM
Is there a "kudzu.conf" or equivalent file slackist Linux - Newbie 7 01-22-2010 09:18 AM
Red hat Install: "No valid devices found on which to create new file systems" Lucky_69 Linux - Software 1 02-06-2007 09:19 PM
"Attempting create too large a file system" suguru Linux - Hardware 2 02-23-2004 01:16 AM
"mkdir: cannot create directory `foo': Read-only file system" on FAT32 maddes Linux - Hardware 1 11-26-2003 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:54 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