Jump to content

Need a little Unix script help


sammaz

Recommended Posts

Sony sent me this test for a job interview and I need a little help...This would be huge for me if anyone can scratch out a quick script to do these simple things.

 

 

 

QUESTION_2 : Basic UNIX commands

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

At Sony we often use a command-line tool named "itstat" which will display the resolution

of an image file and some other lines of information. It accepts a list of image files as arguments (i.e., "itstat FILE1 FILE2..."), and its output looks like this:

 

File: pet_mocap_comp_v1_tvfa_vd8.1713.jpg

Resolution: 720 x 547

Channels: 3

Channel Types: RGB without Alpha

Bit Depth: 8

 

You are in a directory with 50 randomly named and sized images, and

you want to know quickly the resolution of each file.

 

Write a script called `JasonGilbert_getres' that takes no arguments and uses

itstat to print the filename and resolution of each file in the current working

directory in the following format:

 

g50_comp_v6_2kfa_lg10.0310.rla: 2048 x 1556

g50_comp_v6_2kfa_lg10.0610.rla: 2048 x 1556

g50_comp_v6_2kfa_lg10.0710.rla: 2048 x 1556

 

Please name the attachment for question 2 results: JasonGilbert_getres

 

Then, describe how you would use this script to send a list of files

matching the resolution 2048x1556 to a text file named `/tmp/2klist'.

 

Please name the attachment for this description: JasonGilbert_getres_usage

 

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

QUESTION_3 : Scripting skills

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

 

You've just loaded a CD's worth of reference images from an

outside company. The images follow a naming scheme such as

DSCN-1.JPG, DSCN-2.JPG... DSCN-10.JPG, although the frame numbers

may be noncontiguous (i.e., there may be gaps between numbers).

 

Although the frames were stored in separate directories on the

CD-ROM from which they were loaded, all of the frames have now been

placed into this directory:

 

/shots/spi/home/pix/out/home_test_v1/misc_bg8

 

The structure of the directory you've loaded them into is this:

 

/shots/$SHOWNAME/$SHOTNAME/pix/out/$ELEMENTNAME/$RESOLUTION_$COLORSPACE

 

Your task is to rename the frames in accordance with SPI standard

naming conventions. These include:

 

1. No capital letters in the filenames

 

2. No dashes allowed in the filenames

 

3. The images should be re-numbered so that they are a contiguous

sequence (i.e. no gaps)

 

4. Frame numbers need to be padded to four-digits. ie, "1"

becomes "0001" This is denoted by the symbol # so a range of

1-240 would read 1-240#.

 

5. The frames should be renamed to match the directory in which

they are placed in the following manner:

 

$ELEMENTNAME_$RESOLUTION_$COLORSPACE.#.$EXTENSION

 

So, in other words, each frame should become:

 

/shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0001.jpg

/shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0002.jpg

/shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0003.jpg

...

/shots/spi/home/pix/out/home_test_v1/misc_bg8/home_test_v1_misc_bg8.0240.jpg

 

However, the incoming frames are part of a series and must be kept in the exact same

order as they were when loaded (i.e., the incoming frame with the lowest index will

map to `home_test_v1_misc_bg8.0001.jpg', while the second lowest index will map

to `home_test_v1_misc_bg8.0002.jpg', and so on). Hint: sorting by name is not enough!

 

You have a limited time frame to rename these frames, as they are

going to be sent overseas to another house before the end of their

working day. You also have good reason to suspect that there will be

many more requests just like this one.

 

Write a script called `JasonGilbert_cd2spi' that takes a single argument which

will be the directory containing the images described above. Use

the current working directory if no argument is provided. Your

script should then rename all of the images in that directory to

match SPI naming conventions.

 

Sample usage:

$ JasonGilbert_cd2spi /shots/spi/home/pix/out/home_test_v1/misc_bg8

 

 

 

 

 

DIRECTIONS FOR SCRIPTING PARTS OF #2 AND #3

- You will have access to the standard Unix toolset (grep, sort, wc,

etc.).

 

- You may submit your solution in any of the following standard Unix

scripting languages (or a combination). The first line of your

script must include a "shebang" line pointing to the appropriate

executable (e.g., `#!/bin/sh').

 

- sh or bash v2

- csh or tcsh v6

- ksh v5

 

- perl v5

- python v2.3

 

- sed v3

- GNU awk v3

 

- Your script will be executed on a Red Hat Linux machine. Please

try to minimize unnecessary portability problems. You can find

free linux shell accounts on the Internet if you don't have access

to one:

 

http://www.google.com/search?q=free+linux+shell+account

 

- Syntax errors are unacceptable. Test all of your work.

 

- Pay close attention to the input and output requirements stated

below. Deviations from this spec will be penalized heavily.

 

- Your coding style will also be under consideration.

 

- Incomplete submissions will not be considered.

 

 

 

 

If someone can help me with this they will be compensated greatly.

 

Thank you,

 

:afro:

Edited by sammaz
Link to comment
Share on other sites

Just out of curiosity: How well do you know UNIX commands to begin with? I don't quite understand it when you want our help you to pass a test that you alone should do. It tests your skills after all, not ours.

Link to comment
Share on other sites

if u can't pass the test on ur own then even if u get the job, how can u kep the job??

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...