Home | Community | Message Board


This site includes paid links. Please support our sponsors.


Welcome to the Shroomery Message Board! You are experiencing a small sample of what the site has to offer. Please login or register to post messages and view our exclusive members-only content. You'll gain access to additional forums, file attachments, board customizations, encrypted private messages, and much more!

Jump to first unread post Pages: 1
InvisibleOJK
Stranger
 User Gallery
Registered: 06/08/03
Posts: 10,629
linux shell script help
    #5659558 - 05/22/06 09:41 AM (17 years, 8 months ago)

hey,

can anyone give me some pointers on writing a basic linux shell script? Bear in mind, I'm a linux n00b, so be nice :sun:

I'm trying to run "bittorrent-console.py" with a number of variables filled in before hand, but some set at the time the script runs.

I thought something like this might do it;

Quote:

#bittorrent script

$ python bittorrent-console.py --responsefile /%t --save_as /%s --minport 59000 --maxport 62000 --rerequest_interval 15 --display_interval 5 --max_upload_rate /%u




I was hoping that I could save that to script.sh in the same directory as the bittorrent python files, then execute it with something like

$ ah script.sh -t *.torrent -s * -u *

obviously this doesn't work

can anyone give me some pointers? I've had a look at some guides, but they're all kind of dense and start from the novel position that I'm not an idiot  :grin:

thanks for any help


Extras: Filter Print Post Top
InvisibleKrishna
कृष्ण,LOL
 User Gallery

Registered: 05/08/03
Posts: 23,285
Loc: oakland
Re: linux shell script help [Re: OJK]
    #5661680 - 05/22/06 08:29 PM (17 years, 8 months ago)

ok, you want something like

Code:

#!/bin/sh
/usr/bin/python bittorrent-console.py --responsefile $1 --save_as $2 --minport 59000 --maxport 62000 --rerequest_interval 15 --display_interval 5 --max_upload_rate $3



and you'd run it (after chmod'ing exec the script, and assuming it is in the same dir as the .torrent files) via

Code:

./script.sh *.torrent *.mp3 500



or whatever the params were.

you can use $1-$9 for command line args ($0 is the script itself). anymore than that, and you'll have to start shifting. i'm not completely sure if the $1 will work with a wildcard (*) input, though..

this might help..


--------------------




Extras: Filter Print Post Top
InvisibleOJK
Stranger
 User Gallery
Registered: 06/08/03
Posts: 10,629
Re: linux shell script help [Re: Krishna]
    #5663035 - 05/23/06 05:05 AM (17 years, 8 months ago)

thanks man, I'll give it a shot :thumbup:


Extras: Filter Print Post Top
OfflineSeussA
Error: divide byzero

Folding@home Statistics
Registered: 04/27/01
Posts: 23,480
Loc: Caribbean
Last seen: 2 months, 20 days
Re: linux shell script help [Re: OJK]
    #5663076 - 05/23/06 05:49 AM (17 years, 8 months ago)

You may have to make the script executable before you can run it:

% chmod 700 ./script.sh

"chmod" is used to change the file permissions. The 700 tells the system to give the user read, write, and execute permissions while removing all premissions for everybody else. You must be the file owner, or root, to make the change.

Make certain that there is no blank lines or spaces between the top of the script and the #!/bin/sh. These must be the very first characters in the script.


--------------------
Just another spore in the wind.


Extras: Filter Print Post Top
InvisibleOJK
Stranger
 User Gallery
Registered: 06/08/03
Posts: 10,629
Re: linux shell script help [Re: Seuss]
    #5663142 - 05/23/06 06:38 AM (17 years, 8 months ago)

I thought that the "#" commented out anything after it?

I had kind of assumed that. If it's not "#", what's the comment charecter for shell scripts? Is it "::" as with batch files?

Thanks :sun:


Extras: Filter Print Post Top
OfflineSeussA
Error: divide byzero

Folding@home Statistics
Registered: 04/27/01
Posts: 23,480
Loc: Caribbean
Last seen: 2 months, 20 days
Re: linux shell script help [Re: OJK]
    #5663185 - 05/23/06 07:11 AM (17 years, 8 months ago)

For any line but the very first line in a shell script, the # is a comment. For the first line of a shell script, the # is part of the "magic number" that identifies the interpreter to be run to process the script. That is why it is important that there be no lines or spaces between the top of the script and the #!/bin/sh line.

You can use the "file" command to test this:

% file good.sh
good.sh: a /bin/sh script text executable

% file bad.sh
bad.sh: ASCII text


--------------------
Just another spore in the wind.


Extras: Filter Print Post Top
InvisibleOJK
Stranger
 User Gallery
Registered: 06/08/03
Posts: 10,629
Re: linux shell script help [Re: Seuss]
    #5664094 - 05/23/06 12:06 PM (17 years, 8 months ago)

ok, thanks for the help guys

this script seems to do what I want it to -

Code:
#!/bin/sh
python mine/BitTorrent-4.4.0/bittorrent-console.py --responsefile mine/BitTorrent-4.4.0/$1 --save_as mine/BitTorrent-4.4.0/$2 --minport 59000 --maxport 62000 --rerequest_interval 15 --display_interval 5 --max_upload_rate $3



I've uploaded it to my home directory (on the shared server, my home directory is /home/[username]).

I run it with;

Code:
 $ sh bt.sh openoffice.torrent openoffice.rar 100



and it seems to work :sun:

It's probably not the tidiest solution, but it appears to get things done. I just dump everything into my bittorrent directory at the moment.

thank you :sun:

p.s. am I doing anything wrong? :tongue:


Extras: Filter Print Post Top
InvisibleOJK
Stranger
 User Gallery
Registered: 06/08/03
Posts: 10,629
Re: linux shell script help [Re: OJK]
    #5664176 - 05/23/06 12:21 PM (17 years, 8 months ago)

SHIT!

I've been using the "screen" program of debian to leave torrents running when I'm logged off the server. However, it seems that I can only have six "screen" virtual terminals running in the background at a time - when I start a new screen terminal when there are six already running, one of the existing ones dies.

How can I stop this and run more than six at a time?


Extras: Filter Print Post Top
Jump to top Pages: 1


Similar ThreadsPosterViewsRepliesLast post
* linux file system troubles monoamine 963 7 05/22/04 01:55 AM
by AhronZombi
* Differences between freeBSD and linux?
( 1 2 all )
Colonel Kurtz Ph.D 4,708 30 05/01/07 08:52 PM
by delta9
* Installing linux on a Thinkpad 600E - recommendations? OJK 1,899 8 02/13/06 08:30 PM
by debianlinux
* Best Linux/Unix Distribution? *DELETED*
( 1 2 3 all )
T0aD 5,803 52 07/06/04 03:48 PM
by tomu
* Former Gentoo Linux Architect Moves to Microsoft ivi 2,314 19 06/24/05 03:42 PM
by automan
* help with a script
( 1 2 all )
supra 2,104 20 11/27/08 02:13 PM
by zouden
* .mp3 and .mpg player for linux supra 1,204 12 01/27/06 11:00 PM
by supra
* windows/linux user can ya help me? DF2K 1,228 5 06/10/03 08:42 AM
by T0aD

Extra information
You cannot start new topics / You cannot reply to topics
HTML is disabled / BBCode is enabled
Moderator: trendal, automan, Northerner
985 topic views. 0 members, 0 guests and 2 web crawlers are browsing this forum.
[ Show Images Only | Sort by Score | Print Topic ]
Search this thread:

Copyright 1997-2024 Mind Media. Some rights reserved.

Generated in 0.024 seconds spending 0.004 seconds on 12 queries.