View previous topic :: View next topic |
Author |
Message |
99rake99 New Member
Joined: 22 Dec 2025 Posts: 1 Location: NY
|
Posted: Tue Dec 22, 2025 11:54 pm Post subject: shell scripting |
|
|
hi ,
I need to write a shell script for the following requirement . its very urgent plz help mee..
Need to write shell script and it needs accept 4 arguments
4 argument need to pass to main shell script.
If 1st argument is ucsr
call Ucsr.sh (in that ucsr.sh anything doesnt matter 2nd 3rd 4th)
Else if 1st argument is ssp
call Ssp.sh ( in that ssp.sh anything doesnt matter 2nd 3rd 4th)
elseif if 1st argument is ucsr_final
call Ucsrfinal.sh (in that ucsrfinal.sh anything doesnt matter 2nd 3rd 4th)
else if 1st argument is fttp
call fttp.sh (in that ucsr.sh anything doesnt matter 2nd 3rd 4th)
2nd argument should take a table name
3rd argument contractor name ( should be a character)
4th argument a sequence number (should be a number)
thanks in advance..
|
|
Back to top |
|
Germ Keeper of the BIG STICK

Joined: 30 Apr 2025 Posts: 12452 Location: Planet Earth
|
Posted: Wed Dec 23, 2025 1:12 am Post subject: |
|
|
Having trouble with your home work?
_________________ Laptop: Mandriva 2025 PowerPack - 2.6.33.5-0.2mnb
Desktop: Mandriva 2025 Free - kernel 2.6.33.2-1mib
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
|
Back to top |
|
exiled Jr. Member

Joined: 24 Nov 2025 Posts: 51 Location: ~/
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Dec 23, 2025 3:40 am Post subject: |
|
|
For a simple script like that Python would be a bit overkill...
Bash is more than capable of parsing arguments and then executing the appropriate script in response. It can be done in python but Bash is easier.
Bash version (assuming the called scripts handle their own error conditions):
13 lines
19 "words"
152 characters
Python? not implemented but i guarantee larger than that.
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
exiled Jr. Member

Joined: 24 Nov 2025 Posts: 51 Location: ~/
|
Posted: Wed Dec 23, 2025 10:34 am Post subject: |
|
|
It's not about how many words
to accomplish an elif block...
Most likely you can turn 5 individal shell scripts
into 1 Python program.
Each of the 4 call scripts now become a class.
It looks like an object oriented structure to me
and if it's not "shell script homework" then Python
is probably better suited to the task (IMHO).
Of course I have no idea what code the call scripts
contain, but I'm sure Python can reproduce their functionality.
Tomato - Tomoto 
_________________ Currently: Frugalware, Fedora
Previously: Gentoo, Startcom, Debian, Sabayon, Mint, openSUSE, Mangaka Chu, #!CrunchBang
|
|
Back to top |
|
VHockey86 Advanced Member

Joined: 12 Dec 2025 Posts: 988 Location: Rochester
|
Posted: Wed Dec 23, 2025 11:28 am Post subject: |
|
|
Lord.DragonFly.of.Dawn wrote: | For a simple script like that Python would be a bit overkill...
Bash is more than capable of parsing arguments and then executing the appropriate script in response. It can be done in python but Bash is easier.
Bash version (assuming the called scripts handle their own error conditions):
13 lines
19 "words"
152 characters
Python? not implemented but i guarantee larger than that. |
Admittedly I don't understand what he wanted done with the 2nd,3rd,4th arguments...but the rest is a trival 4 line script, 3 if you don't count imports.
If they're supposed to be passed to the other script then its essentially the same thing just with a string formatting statment inside the system call.
Code: |
import sys,os
script_map = {'ucsr':'Ucsr.sh', 'ssp':'Ssp.sh', 'ucsr_final':'Ucsrfinal.sh','fttp':'fttp.sh'}
table,contractor,number = sys.argv[2:5]
os.system(script_map[sys.argv[1]])
|
_________________ Main Desktops : Kubuntu 10.4. ArchLinux 64-bit. Windows7 64-bit. Windows XP 32-bit.
MacBook: OS X Snow Leopard (10.6)
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Wed Dec 23, 2025 10:31 pm Post subject: |
|
|
hmm.... okay, shorter than I had expected....
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
crouse Site Admin

Joined: 17 Apr 2025 Posts: 11833 Location: Iowa
|
Posted: Thu Dec 24, 2025 12:38 am Post subject: |
|
|
pfffffffft how many lines ....really? A shell script CAN all be on ONE line, doesn't mean it SHOULD be.
The OP ask about shell scripting, sort of rude to ask him to use a whole different language just because you prefer it. Now before you start complaining, there are so many languages that can be used with Linux, that I GUARANTEE you that a perl guru would argue that it is best done in perl, a ruby guru ruby, etc etc etc.
And those of you that think shell scripting is inferior to all other languages ...... BAH, I am very proficient in shell scripting, and can do things with bash you wouldn't believe a shell script can do. I have written many shell scripts that exceed 500 lines, and they are commented well, and EASY to maintain. jbsnake is the bash guru though, and i've seen him write stuff so fast it will make your head spin, and routinely writes shell scripts that work in place of other languages like perl/python etc....... sometimes, it's just what you know best. He has working solutions before the programmers have even started coding Since I am more of a procedural coder, (but am trying to master python ) I love the shell.
Obviously this was homework
So to the OP, if you EVER come back ... good luck with your homework, we can HELP you, but no one will do your work for you. You won't learn anything that way 
_________________ Veronica - Arch Linux 64-bit -- Kernel 2.6.33.4-1
Archie/Jughead - Arch Linux 32-bit -- Kernel 2.6.33.4-1
Betty/Reggie - Arch Linux (VBox) 32-bit -- Kernel 2.6.33.4-1
BumbleBee - OpenSolaris-SunOS 5.11
|
|
Back to top |
|
exiled Jr. Member

Joined: 24 Nov 2025 Posts: 51 Location: ~/
|
Posted: Thu Dec 24, 2025 1:14 am Post subject: |
|
|
crouse wrote: | pfffffffft how many lines ....really? A shell script CAN all be on ONE line, doesn't mean it SHOULD be.
The OP ask about shell scripting, sort of rude to ask him to use a whole different language just because you prefer it. |
Did you say rude? Yes that would be me. (Ha! Ha! Ha!)
Actually, I prefer tcl over bash and bash over python,
but your correct homework boy did say shell script, so
I'll keep my superior suggestions to myself.
I am kidding... There is no way I can't keep suggestions to myself
good thread 
_________________ Currently: Frugalware, Fedora
Previously: Gentoo, Startcom, Debian, Sabayon, Mint, openSUSE, Mangaka Chu, #!CrunchBang
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Thu Dec 24, 2025 2:56 am Post subject: |
|
|
crouse wrote: | pfffffffft how many lines ....really? A shell script CAN all be on ONE line, doesn't mean it SHOULD be.
-snip-
And those of you that think shell scripting is inferior to all other languages ...... BAH, I am very proficient in shell scripting, and can do things with bash you wouldn't believe a shell script can do. I have written many shell scripts that exceed 500 lines, and they are commented well, and EASY to maintain. jbsnake is the bash guru though, and i've seen him write stuff so fast it will make your head spin, and routinely writes shell scripts that work in place of other languages like perl/python etc....... sometimes, it's just what you know best. He has working solutions before the programmers have even started coding ;) Since I am more of a procedural coder, (but am trying to master python ;) ) I love the shell. |
I should have qualified....
the bash script was spaced in a readable way (although lacking comments) and was extremely simple.
As for bash coding... Did you know you can do audio postprocessing in bash using read, arrays, exho, and bc?
just because you can doesn't mean you should. that monsterous 1000 line bash script duplicated about a tenth of a tenth of a percent of the functionality of SoX and was not portable (it relied on the behavior of a SPECIFIC audio card driver version, to the point that a kernel update broke it) and was a nightmare to read.
on the other hand you can do pretty amazing things with it too, like writing an auto DJ, automating the remastering of audiobooks (using SoX, normalize and others like it should do), and thousands of other tasks.
of course i'm not aware of a single linux distribution that doesn't rely heavily on bash scripts for system boot.
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
platinummonkey Advanced Member

Joined: 01 Mar 2025 Posts: 732 Location: Texas
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Thu Dec 24, 2025 4:49 am Post subject: |
|
|
platinummonkey wrote: | Lord.DragonFly.of.Dawn wrote: | of course i'm not aware of a single linux distribution that doesn't rely heavily on bash scripts for system boot. |
... you shouldn't tempt me :P lol |
please do prove me wrong. I'd love to get to know some of the more esoteric distributions.
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
crouse Site Admin

Joined: 17 Apr 2025 Posts: 11833 Location: Iowa
|
Posted: Thu Dec 24, 2025 5:06 am Post subject: |
|
|
Lord.DragonFly.of.Dawn wrote: | of course i'm not aware of a single linux distribution that doesn't rely heavily on bash scripts for system boot. |
Pardus (i think it uses python)...not positive, and i think slackware had some replacement type scripts for some things...but it's been awhile since i've played with slack.
The only bane of shell scripting for me is the speed differences between the shell and other languages. It's not uncommon for me to have to parse thousands of documents , and while perl is MUCH faster, I've been working on learning python, which is probably not as fast as perl, but close.
_________________ Veronica - Arch Linux 64-bit -- Kernel 2.6.33.4-1
Archie/Jughead - Arch Linux 32-bit -- Kernel 2.6.33.4-1
Betty/Reggie - Arch Linux (VBox) 32-bit -- Kernel 2.6.33.4-1
BumbleBee - OpenSolaris-SunOS 5.11
|
|
Back to top |
|
Lord.DragonFly.of.Dawn Advanced Member

Joined: 18 Jul 2025 Posts: 607 Location: South Portland, Maine, USA, Earth, Sol System
|
Posted: Thu Dec 24, 2025 12:19 pm Post subject: |
|
|
yeah... spawning subshells, which happens a *LOT* in shell scfipting, is not the cheapest of operations...
that's bitten me quite a few times before.
_________________ ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)
PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
|
|
Back to top |
|
|