1st yr Exam revision thread - Scripts, C, Commands
Hello, I have an exam for 1st year Linux and Unix programming coming up in a week and I need some help going over the past exams, I want to make sure I'm getting the right answers in the past exams to ensure full marks.
The internet is a distraction so making this thread will hopefully help me focus! Also, it will be good revision for anyone else in the same boat, while hopfully helping me commit it to memory and understand it better, and the questions should be pretty easy
1. Write a bash script for the minimum program that works as follows: Heres my answer: Pseudocode:
If
arg1 is less than arg2
output: "the minimum of arg1 and arg2 is arg1"
else
output: "the minimum of arg1 and arg2 is arg2"
Is my algorithm correct? The program compiles, but when I run it I get syntax error. What is the correct syntax please help.
---------- Post updated at 11:13 AM ---------- Previous update was at 10:43 AM ----------
Figured it out
It works and outputs correctly. Do you think this answer would get full marks in an exam?
I have been trying to run a unix script which contains many sql statements.I need to run this script every monday morning. I tried to run on command prompt, it works fine. But while I run it via batch or at command., it returns with library module could not be loaded (libcompat.1.o could not be... (3 Replies)
can anyone help me in writing a shell script to visualize how simple commands work and on what logic. For Eg: ls command how it lists out all the files and directories, need to write a simple script based on the commands source code.:D (0 Replies)
Hello everyone. I am new to writing scripts and I am trying to figure out how to get it to work on a unix system. I am currently using windows xp to write my scripts. My questions are:
1. If the scripts are writtin in Wordpad, what do I save them as before converting them on unix?
2. After... (3 Replies)
Hello,
the bulk of my work is run by scripts. An example is as such:
#!/bin/bash
awk '{print first line}' Input.in > Intermediate.ter
awk '{print second line}' Input.in > Intermediate_2.ter
command Intermediate.ter Intermediate_2.ter > Output.out
It works the way I want it to, but it's not... (1 Reply)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Write an awk script(company.awk) for the workers file to find the number of workers of each departman, total... (8 Replies)
I have a shell script which executes to write html codes into a text file. My next step is to email the text file so that receiving person (people who i send email to) should be able to see pie/chart or bar graph (whatever i design in my code) in their email. Following is the example of a sample... (7 Replies)
Hi guys,
Hoping someone can help with the below - involves basic commands and some scripting. Thanks so much in advance for your amazing time and help.
3. The file /etc/profile contains the default initialization options for your shell.
Produce a unique list of all variables with uppercase... (1 Reply)
In a Redhat Linux environment, I could run salt commands on the $ prompt but not inside my bash scripts.
It will say command not found and the $PATH variable is exactly the same outside and inside the script.
!#/usr/bin/bash
echo “running”¯
salt "*" cmd.run ‘ls'
exit
Output:-... (8 Replies)
Discussion started by: gurudewa
8 Replies
LEARN ABOUT DEBIAN
thread::pool::simple
Simple(3pm) User Contributed Perl Documentation Simple(3pm)NAME
Thread::Pool::Simple - A simple thread-pool implementation
SYNOPSIS
use Thread::Pool::Simple;
my $pool = Thread::Pool::Simple->new(
min => 3, # at least 3 workers
max => 5, # at most 5 workers
load => 10, # increase worker if on average every worker has 10 jobs waiting
init => [&init_handle, $arg1, $arg2, ...] # run before creating worker thread
pre => [&pre_handle, $arg1, $arg2, ...] # run after creating worker thread
do => [&do_handle, $arg1, $arg2, ...] # job handler for each worker
post => [&post_handle, $arg1, $arg2, ...] # run before worker threads end
passid => 1, # whether to pass the job id as the first argument to the &do_handle
lifespan => 10000, # total jobs handled by each worker
);
my ($id1) = $pool->add(@arg1); # call in list context
my $id2 = $pool->add(@arg2); # call in scalar conetxt
$pool->add(@arg3) # call in void context
my @ret = $pool->remove($id1); # get result (block)
my $ret = $pool->remove_nb($id2); # get result (no block)
$pool->cancel($id1); # cancel the job
$pool->cancel_all(); # cancel all jobs
$pool->join(); # wait till all jobs are done
$pool->detach(); # don't wait.
DESCRIPTION
"Thread::Pool::Simple" provides a simple thread-pool implementaion without external dependencies outside core modules.
Jobs can be submitted to and handled by multi-threaded `workers' managed by the pool.
AUTHOR
Jianyuan Wu, <jwu@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2007 by Jianyuan Wu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2010-10-04 Simple(3pm)