Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 24 May 2018, 02:27
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
Script file or batch file
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
cruzin


Joined: 30 Nov 2006
Posts: 173

PostPosted: Sun 15 Jul 2007, 09:36    Post subject:  Script file or batch file
Subject description: How can I make?
 

Hello, I did a search for script and did not find much on it that would help me to make one. I have a notebook, I take it with me sometimes while working away. Its a thinkpad t21 256 ram, 20 gig hdd. I do NOT have windoz or any other systems on the t21, I use puppy 2.14 from cd and not live cd as my t21 does not have a burner. I have a netgear wireless card that I use for hot spots. I have no problem getting on line with it wireless using modprobe, ifconfig and using the RutilT gaget to find and connect to networks. I have not been able to have it save the wireless profiles.
Can I make a script file or batch file and place it on my desktop to run Modprobe and ifconfig at the click of a icon? If so can someone explain to me how to make it and where in puppy to place it? thanks
Back to top
View user's profile Send private message 
Bruce B

Joined: 18 May 2005
Posts: 11488
Location: The Peoples Republic of California

PostPosted: Sun 15 Jul 2007, 10:02    Post subject:  

Where to place it?

I put my scripts in /root/bin, this way they don't get lost

I have to make the directory and then put /root/bin in the search path. I do this by editing /etc/profile and add the directory to the search path

How to make the script

Convention has us do the first line like this:
#!/bin/sh

A simple script would involve entering your commands, keeping in mind they will be executed from top to bottom of file.

The script must have the execute attribute, this can be accomplished by this command

# chmod 755 myscriptname

Example

Code:
#!/bin/sh
# this simple script mounts hdc1 formatted as ext3 at /mnt/hdc1
# then displays top level files and directories
mount -t ext3 /dev/hdc1 /mnt/hdc1
ls /mnt/hdc1


Placing shortcut on desktop

Open ROX-Filer, find the script, drag and drop to desktop, name as you please, find an appropriate icon for it.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6542
Location: Valåmoen, Norway

PostPosted: Sun 15 Jul 2007, 11:02    Post subject:  

here's my script to connect my wireless usb-device.
I have made some comments for you (#comments)

Code:
#!/bin/bash
TMP=`lsmod | grep "rt73"` #check if module rf73 is loaded (driver for my wifi)
if [ -n $TMP ]; then #if not...
   modprobe rt73 #...load
fi
ifconfig rausb0 up #activate wifi device
sleep 1 #wait 1 second
iwconfig rausb0 essid default mode Managed #connect to the open net called 'default'
sleep 1
rm -f /etc/dhcpc/dhcpcd-*.pid #remove old configfile

PS=`ps`
TMP= `echo $PS | grep "dhcpcd"` #check if dhchcd is running (get dynamic ip-adress
if test -n $TMP; then #if not...
   dhcpcd rausb0 #...do
fi
TMP= `echo $PS | grep "rutilt"`
if test -n $TMP; then
   rutilt -t &
fi
TMP= `echo $PS | grep "seamonkey"`
if test -n $TMP; then
   mozilla
fi

Good luck

Sigmund
Back to top
View user's profile Send private message Visit poster's website 
cruzin


Joined: 30 Nov 2006
Posts: 173

PostPosted: Sun 15 Jul 2007, 11:14    Post subject: my attempt
Subject description: failed
 

I went to dir bin and right or left clicked on no icon and choose (new file) and found that It listed (scritp) so I choose that and made a script file I found that when I choose new script that it opened up with the line opened up the abiword and #!/bin/sh so I added modprobe ath_pci and also ifconfig ath0 up which is the commands I use in console to load up the netgear card and make it active. I saved it and linked it to the desktop and it did not work then I tried just making a text file and tried it and it still did not work. Im looking over both replies more to see if I (newbie) can make sense of it. thanks for the help. Ill go through and change what I think I should and try it. this is what I have so far. That did not work..
#!/bin/sh
#modprobe ath_pci
#ifconfig ath0 up
Back to top
View user's profile Send private message 
cruzin


Joined: 30 Nov 2006
Posts: 173

PostPosted: Sun 15 Jul 2007, 11:24    Post subject: Re: my attempt
Subject description: failed
 

cruzin wrote:
I went to dir bin and right or left clicked on no icon and choose (new file) and found that It listed (scritp) so I choose that and made a script file I found that when I choose new script that it opened up with the line opened up the abiword and #!/bin/sh so I added modprobe ath_pci and also ifconfig ath0 up which is the commands I use in console to load up the netgear card and make it active. I saved it and linked it to the desktop and it did not work then I tried just making a text file and tried it and it still did not work. Im looking over both replies more to see if I (newbie) can make sense of it. thanks for the help. Ill go through and change what I think I should and try it. this is what I have so far. That did not work..
#!/bin/sh
#modprobe ath_pci
#ifconfig ath0 up


I tried this edited file and did the execute afterwords and it told me no such device

#!/bin/sh
#!/bin/bash
TMP=`lsmod | grep "ath_pci"` #check if module ath0 is loaded (driver for my wifi)
if [ -n $TMP ]; then #if not...
modprobe ath_pci #...load
fi
ifconfig ath0 up #activate wifi device
sleep 1 #wait 1 second

as I do not know what lsmod | grep means I dont know if that is the problem..

above I listed what I do in the console to get my wireless card working
modprobe ath_pci
ifconfig ath0 up

then I get the wireless working and go to Rutil gaget

any more suggestions as you look what Ive tried? thanks again
Back to top
View user's profile Send private message 
cruzin


Joined: 30 Nov 2006
Posts: 173

PostPosted: Sun 15 Jul 2007, 11:28    Post subject:  

Bruce B wrote:
Where to place it?

I put my scripts in /root/bin, this way they don't get lost

I have to make the directory and then put /root/bin in the search path. I do this by editing /etc/profile and add the directory to the search path

How to make the script

Convention has us do the first line like this:
#!/bin/sh

A simple script would involve entering your commands, keeping in mind they will be executed from top to bottom of file.

The script must have the execute attribute, this can be accomplished by this command

# chmod 755 myscriptname

Example

Code:
#!/bin/sh
# this simple script mounts hdc1 formatted as ext3 at /mnt/hdc1
# then displays top level files and directories
mount -t ext3 /dev/hdc1 /mnt/hdc1
ls /mnt/hdc1


Placing shortcut on desktop

Open ROX-Filer, find the script, drag and drop to desktop, name as you please, find an appropriate icon for it.

When you said I need the chmod 755 to make it a run file is that the sme as clicking on the execute at the top of the file? and do I need the # at the beggining of each line? I always thought that when you added a # at the beggining of a line that then it was just comments and not commands. That may be from dos not sure. thanks
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5087
Location: Arizona, U.S.A.

PostPosted: Sun 15 Jul 2007, 11:46    Post subject:  

Yes, a # is a comment, except for the script specifier at the start of the file.
The # you see at the start of the line is Puppy's command prompt.

The normal place to put stuff like this is: /root/my-applications/bin
It's in the path already so there's no need to change the path.

I myself tend to like short dir. names like: /apps, /docs, etc.
Back to top
View user's profile Send private message 
Sit Heel Speak


Joined: 30 Mar 2006
Posts: 2595
Location: downwind

PostPosted: Sun 15 Jul 2007, 12:25    Post subject:  

cruzin wrote:
When you said I need the chmod 755 to make it a run file is that the sme as clicking on the execute at the top of the file?

No. Open Rox, navigate to wherever you have placed your script, right-click-on-white-space, Window-->Open Terminal Here, this will open an console window at the bash prompt. Now execute the chmod command as a command line, e.g.

# chmod 755 myscriptname

(don't type the "#", that's the prompt)

Now your script will execute.
Back to top
View user's profile Send private message 
trapster


Joined: 28 Nov 2005
Posts: 2108
Location: Maine, USA

PostPosted: Sun 15 Jul 2007, 12:31    Post subject:  

To make your file executable, right click on it and choose "permissions" when the window pops up, click yes if it shows "a+x (make executable)".
_________________
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog
Back to top
View user's profile Send private message Visit poster's website 
cruzin


Joined: 30 Nov 2006
Posts: 173

PostPosted: Mon 16 Jul 2007, 09:51    Post subject: scritp file
Subject description: no success
 

Hi, thanks for all the suggestions
I have not been able to make it work as of yet.

This is what Ive done.

I went to the /bin folder, created a file called wireless, the file reads

#/bin/sh
modprobe ath_pci
ifconfig ath0 up

thats all I wrote I saved it and then went to the /bin folder and right clicked in the white and opened window and typed the chdmod 755 wireless which is what I named the file. closed the window. I deleted the icon I had on the desktop and re draged the new one over to the desktop , I then restarted the computer and clicked on the desktop icon and nothing happened. I went to my consol window to check if the ifconfig had anything about my ath0 being up and it did not list it. So I know that modprobe did not work.

Got a couple questions.
In the first line of the file

#/bin/sh (what does the letters /sh mean?) is sh the file name? should it read like this (#/bin/wireless)? being wireless is my file name?

and if starting up my pcmcia wireless card I always go to the console and type modprobe ath_pci enter
then I type ifconfig ath) up is this all I need to make the script

and to make sure ive placed it in the right place it located in
/bin

How does this look and sound? thanks again for the help.
Back to top
View user's profile Send private message 
cruzin


Joined: 30 Nov 2006
Posts: 173

PostPosted: Mon 16 Jul 2007, 10:27    Post subject: working now
Subject description: success
 

Thanks all for the help. its working now.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6542
Location: Valåmoen, Norway

PostPosted: Mon 16 Jul 2007, 10:59    Post subject:  

#/bin/sh (what does the letters /sh mean?)

It tell system to use /bin/sh to run this script. You have made a shell-script (sh). - Congratulations. They are very useful, and Puppy is full of them.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0671s ][ Queries: 11 (0.0175s) ][ GZIP on ]